changeset 19:28fcf9993b62

Remove not longer used functions. emeraldtree/ElementTree.py - Remove Element.makeelement. - Remove Element.__getslice__, Element.__setslice__ and Element.__delslice__. - Redefine __getitem__ and __delitem__. - Make __setitem__ away of slice objects.
author Bastian Blank <bblank@thinkmo.de>
date Sat, 31 May 2008 19:07:35 +0200
parents 42e1c75e8bcb
children 56cb25aba1e6
files emeraldtree/ElementTree.py
diffstat 1 files changed, 8 insertions(+), 46 deletions(-) [+]
line wrap: on
line diff
--- a/emeraldtree/ElementTree.py	Sat May 31 19:05:29 2008 +0200
+++ b/emeraldtree/ElementTree.py	Sat May 31 19:07:35 2008 +0200
@@ -204,16 +204,6 @@
         return "<Element %s at %x>" % (repr(self.tag), id(self))
 
     ##
-    # Creates a new element object of the same type as this element.
-    #
-    # @param tag Element tag.
-    # @param attrib Element attributes, given as a dictionary.
-    # @return A new element instance.
-
-    def makeelement(self, tag, attrib):
-        return Element(tag, attrib)
-
-    ##
     # Returns the number of subelements.
     #
     # @return The number of subelements.
@@ -229,7 +219,7 @@
     # @exception IndexError If the given element does not exist.
 
     def __getitem__(self, index):
-        return self._children[index]
+        return self._children.__getitem__(index)
 
     ##
     # Replaces the given subelement.
@@ -240,8 +230,12 @@
     # @exception AssertionError If element is not a valid object.
 
     def __setitem__(self, index, element):
-        assert iselement(element)
-        self._children[index] = element
+        if isinstance(index, slice):
+            for elem in element:
+                assert iselement(elem)
+        else:
+            assert iselement(element)
+        self._children.__setitem__(index, element)
 
     ##
     # Deletes the given subelement.
@@ -250,39 +244,7 @@
     # @exception IndexError If the given element does not exist.
 
     def __delitem__(self, index):
-        del self._children[index]
-
-    ##
-    # Returns a list containing subelements in the given range.
-    #
-    # @param start The first subelement to return.
-    # @param stop The first subelement that shouldn't be returned.
-    # @return A sequence object containing subelements.
-
-    def __getslice__(self, start, stop):
-        return self._children[start:stop]
-
-    ##
-    # Replaces a number of subelements with elements from a sequence.
-    #
-    # @param start The first subelement to replace.
-    # @param stop The first subelement that shouldn't be replaced.
-    # @param elements A sequence object with zero or more elements.
-    # @exception AssertionError If a sequence member is not a valid object.
-
-    def __setslice__(self, start, stop, elements):
-        for element in elements:
-            assert iselement(element)
-        self._children[start:stop] = list(elements)
-
-    ##
-    # Deletes a number of subelements.
-    #
-    # @param start The first subelement to delete.
-    # @param stop The first subelement to leave in there.
-
-    def __delslice__(self, start, stop):
-        del self._children[start:stop]
+        self._children.__delitem__(index)
 
     ##
     # Adds a subelement to the end of this element.