summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDipesh Amin <yaypunkrock@gmail.com>2011-08-22 13:06:51 +0100
committerDipesh Amin <yaypunkrock@gmail.com>2011-08-22 13:06:51 +0100
commit2cb97b9da0caf0e44134f483b882d54570405f75 (patch)
treef1ae3b351ee145c382643cb56663641c049ad611
parentc38c4a477833507e04b1779a11a45f0c28cb60cc (diff)
downloadmanamarket-2cb97b9da0caf0e44134f483b882d54570405f75.tar.gz
manamarket-2cb97b9da0caf0e44134f483b882d54570405f75.tar.bz2
manamarket-2cb97b9da0caf0e44134f483b882d54570405f75.tar.xz
manamarket-2cb97b9da0caf0e44134f483b882d54570405f75.zip
Add pretty xml printing using xml.dom.minidom.
-rw-r--r--tradey.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/tradey.py b/tradey.py
index 8ec6c6b..b70fd24 100644
--- a/tradey.py
+++ b/tradey.py
@@ -8,6 +8,7 @@
"""
import time
import os
+import xml.dom.minidom
from subprocess import call
from xml.etree.ElementTree import *
@@ -43,8 +44,10 @@ class UserTree:
def save(self):
# Be sure to call save() after any changes to the tree.
- self.tree = ElementTree(self.root)
- self.tree.write("data/user.xml")
+ f = open('data/user.xml', 'w')
+ dom = xml.dom.minidom.parseString(tostring(self.root))
+ f.write(str(dom.toprettyxml(' ')))
+ f.close()
class ItemTree:
def __init__(self):
@@ -94,8 +97,10 @@ class ItemTree:
def save(self):
# Be sure to call save() after any changes to the tree.
- self.tree = ElementTree(self.root)
- self.tree.write("data/sale.xml")
+ f = open('data/sale.xml', 'w')
+ dom = xml.dom.minidom.parseString(tostring(self.root))
+ f.write(str(dom.toprettyxml(' ')))
+ f.close()
def saveData(commitmessage = "commit"):
# This assumes the current working directory is the tradey directory.