changeset 95:5413661e5765

remove redundant code from tostring(list) functions, use new-style class, add method param to tostringlist function
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 23 Dec 2012 19:04:57 +0100
parents 08992651df1f
children 3f325a667871
files emeraldtree/tree.py
diffstat 1 files changed, 4 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/emeraldtree/tree.py	Sun Dec 23 19:03:42 2012 +0100
+++ b/emeraldtree/tree.py	Sun Dec 23 19:04:57 2012 +0100
@@ -668,12 +668,7 @@
 # @defreturn string
 
 def tostring(element, encoding=None, method=None):
-    class dummy:
-        pass
-    data = []
-    file = dummy()
-    file.write = data.append
-    ElementTree(element).write(file, encoding, method=method)
+    data = tostringlist(element, encoding, method)
     return "".join(data)
 
 ##
@@ -685,13 +680,13 @@
 # @defreturn sequence
 # @since 1.3
 
-def tostringlist(element, encoding=None):
-    class dummy:
+def tostringlist(element, encoding=None, method=None):
+    class dummy(object):
         pass
     data = []
     file = dummy()
     file.write = data.append
-    ElementTree(element).write(file, encoding)
+    ElementTree(element).write(file, encoding, method=method)
     # FIXME: merge small fragments into larger parts
     return data