diff options
author | Dipesh Amin <yaypunkrock@gmail.com> | 2011-08-22 13:06:51 +0100 |
---|---|---|
committer | Dipesh Amin <yaypunkrock@gmail.com> | 2011-08-22 13:06:51 +0100 |
commit | 2cb97b9da0caf0e44134f483b882d54570405f75 (patch) | |
tree | f1ae3b351ee145c382643cb56663641c049ad611 | |
parent | c38c4a477833507e04b1779a11a45f0c28cb60cc (diff) | |
download | manamarket-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.py | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -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. |