diff emeraldtree/ElementTree.py @ 23:4c1912ff58a3

Support initialization with children. * emeraldtree/ElementTree.py - Add children argument to Element.__init__. - Style fixes. * emeraldtree/tests/test_ElementTree.py - Use children init. - Check for unicode.
author Bastian Blank <bblank@thinkmo.de>
date Fri, 06 Jun 2008 21:57:12 +0200
parents 0aa00b020bc1
children 47ae505e63ea
line wrap: on
line diff
--- a/emeraldtree/ElementTree.py	Fri Jun 06 20:56:42 2008 +0200
+++ b/emeraldtree/ElementTree.py	Fri Jun 06 21:57:12 2008 +0200
@@ -183,12 +183,12 @@
     def tail(self):
         raise RuntimeError('The tail argument is not supported')
 
-    def __init__(self, tag, attrib={}, **extra):
+    def __init__(self, tag, attrib={}, children=[], **extra):
         attrib = attrib.copy()
         attrib.update(extra)
         self.tag = tag
         self.attrib = attrib
-        self._children = []
+        self._children = children[:]
 
     def __repr__(self):
         return "<Element %s at %x>" % (repr(self.tag), id(self))
@@ -475,7 +475,7 @@
 # @return An opaque object, representing the QName.
 
 class QName(object):
-    def __init__(self, text, uri = None):
+    def __init__(self, text, uri=None):
         if text[0] == '{':
             if uri is not None:
                 raise ValueError