Commits

Anonymous committed d9ac9fe

Tree - Allow all objects in tree

Comments (0)

Files changed (1)

emeraldtree/tree.py

         attrib.update(extra)
         self.tag = tag
         self.attrib = attrib
-        self._children = [self._check_node(i) for i in children]
+        self._children = list(children)
 
     def __repr__(self):
         return "<Element %s at %x>" % (repr(self.tag), id(self))
     # @exception AssertionError If element is not a valid object.
 
     def __setitem__(self, index, element):
-        if isinstance(index, slice):
-            element = [self._check_node(i) for i in element]
-        else:
-            element = self._check_node(element)
         self._children.__setitem__(index, element)
 
     ##
     def __delitem__(self, index):
         self._children.__delitem__(index)
 
-    @staticmethod
-    def _check_node(node):
-        if isinstance(node, (Node, unicode)):
-            return node
-        if isinstance(node, str):
-            return unicode(node)
-        raise TypeError
-
     ##
     # Adds a subelement to the end of this element.
     #
     # @exception AssertionError If a sequence member is not a valid object.
 
     def append(self, element):
-        element = self._check_node(element)
         self._children.append(element)
 
     ##
     # @since 1.3
 
     def extend(self, elements):
-        elements = [self._check_node(i) for i in elements]
         self._children.extend(elements)
 
     ##
     # @exception AssertionError If the element is not a valid object.
 
     def insert(self, index, element):
-        element = self._check_node(element)
         self._children.insert(index, element)
 
     ##