From: Leandro Lucarella Date: Tue, 16 Oct 2007 00:02:34 +0000 (-0300) Subject: Add a clear() method to ContainerSubHandler to remove all the items. X-Git-Url: https://git.llucax.com/software/pymin.git/commitdiff_plain/066b7ef8b45149aec09d41ca74b08d0b8711cb13?hp=3660782f64b0e3dfc2db4b1bfce4c59b4b46e3fc Add a clear() method to ContainerSubHandler to remove all the items. --- diff --git a/pymin/services/util.py b/pymin/services/util.py index b665c00..2fe7f9b 100644 --- a/pymin/services/util.py +++ b/pymin/services/util.py @@ -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."