[Formed-commits] r289 - in trunk: . formed/formed formed/formed/io

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Aug 21 13:05:17 CEST 2008


Author: teichmann
Date: 2008-08-21 13:05:17 +0200 (Thu, 21 Aug 2008)
New Revision: 289

Modified:
   trunk/ChangeLog
   trunk/formed/formed/io/document.py
   trunk/formed/formed/main.py
Log:
Indent formed-tree while saving


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-08-15 14:00:35 UTC (rev 288)
+++ trunk/ChangeLog	2008-08-21 11:05:17 UTC (rev 289)
@@ -1,3 +1,8 @@
+2008-08-21	Sascha L. Teichmann <teichmann at intevation.de>
+
+	* formed/formed/io/document.py: Indent tree while saving
+	* formed/formed/main.py: removed needless print
+
 2008-08-15	Sascha L. Teichmann <teichmann at intevation.de>
 
 	* LICENSE: New GPLv3

Modified: trunk/formed/formed/io/document.py
===================================================================
--- trunk/formed/formed/io/document.py	2008-08-15 14:00:35 UTC (rev 288)
+++ trunk/formed/formed/io/document.py	2008-08-21 11:05:17 UTC (rev 289)
@@ -102,17 +102,19 @@
     if x: return u" %s" % x
     return x
 
-def _toXML(nc):
+def _toXML(nc, depth = 0):
+    indent = "  " * depth
     if isinstance(nc, Node):
         tagName = classesToTagNames.get(nc.__class__, "node")
-        out = [ u"<%s%s>" % (tagName, _attributesToXML(nc)) ]
+        out = [ u"%s<%s%s>" % (indent, tagName, _attributesToXML(nc)) ]
+        next_depth = depth + 1
         for child in nc.children:
-            out.append(_toXML(child))
-        out.append(u"</%s>" % tagName)
-        return "".join(out)
+            out.append(_toXML(child, next_depth))
+        out.append(u"%s</%s>" % (indent, tagName))
+        return "\n".join(out)
     if isinstance(nc, Leaf):
         tagName = classesToTagNames.get(nc.__class__, "leaf")
-        return u"<%s%s/>" % (tagName, _attributesToXML(nc))
+        return u"%s<%s%s/>" % (indent, tagName, _attributesToXML(nc))
     if isinstance(nc, Document):
         out = [ u'<?xml version="1.0" encoding="UTF-8"?>\n' ]
         out.append(_toXML(nc.root))

Modified: trunk/formed/formed/main.py
===================================================================
--- trunk/formed/formed/main.py	2008-08-15 14:00:35 UTC (rev 288)
+++ trunk/formed/formed/main.py	2008-08-21 11:05:17 UTC (rev 289)
@@ -563,7 +563,6 @@
 
 def main(argv = []):
     localedir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "resources", "locale")
-    print localedir
     gettext.install('formed', localedir, unicode=True)
     wx.Locale.AddCatalogLookupPathPrefix(localedir)
     wxLoc = wx.Locale(wx.LANGUAGE_DEFAULT)



More information about the Formed-commits mailing list