]> git.llucax.com Git - software/pymin.git/commitdiff
Add a clear() method to ContainerSubHandler to remove all the items.
authorLeandro Lucarella <llucax@gmail.com>
Tue, 16 Oct 2007 00:02:34 +0000 (21:02 -0300)
committerLeandro Lucarella <llucax@gmail.com>
Tue, 16 Oct 2007 00:02:34 +0000 (21:02 -0300)
pymin/services/util.py

index b665c00e173dd4624e221018a579702628a7fc50..2fe7f9b6d45e3d9dcabdeb8f09c0670c5a92392a 100644 (file)
@@ -721,6 +721,13 @@ class ContainerSubHandler(SubHandler):
         except IndexError:
             raise ItemNotFoundError(index)
 
+    @handler(u'Remove all items (use with care).')
+    def clear(self):
+        if isinstance(self._attr(), dict):
+            self._attr.clear()
+        else:
+            self._attr(list())
+
     @handler(u'Get information about an item')
     def get(self, index):
         r"get(index) -> item :: List all the information of an item."