diff options
author | Olivier Tilloy <olivier@tilloy.net> | 2009-05-04 09:55:38 +0200 |
---|---|---|
committer | Olivier Tilloy <olivier@tilloy.net> | 2009-05-04 09:55:38 +0200 |
commit | 8189c1ee21be899f090eef7211c12e10a11a9f53 (patch) | |
tree | d9c7b79c8a54d75a045694458ea66ac3c4f81e17 /src | |
parent | 746e780f6ff679616441cf2ee9d8d2cc5e570307 (diff) | |
download | pyexiv2-8189c1ee21be899f090eef7211c12e10a11a9f53.tar.gz |
NotifyingList: implementation of reverse, sort, __iadd__, __imul__.
Diffstat (limited to 'src')
-rw-r--r-- | src/pyexiv2.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/pyexiv2.py b/src/pyexiv2.py index d39edfa..ca0506f 100644 --- a/src/pyexiv2.py +++ b/src/pyexiv2.py @@ -281,6 +281,8 @@ class NotifyingList(list): # file:///usr/share/doc/python2.5/html/lib/typesseq-mutable.html # http://docs.python.org/reference/datamodel.html#additional-methods-for-emulation-of-sequence-types + # FIXME: support negatives indexes where relevant + def __init__(self, items=[]): super(NotifyingList, self).__init__(items) self._listeners = set() @@ -332,16 +334,24 @@ class NotifyingList(list): self._notify_listeners('items_deleted', index, index + 1) def reverse(self): - raise NotImplementedError() + super(NotifyingList, self).reverse() + self._notify_listeners('reordered') def sort(self, cmp=None, key=None, reverse=False): - raise NotImplementedError() + super(NotifyingList, self).sort(cmp, key, reverse) + self._notify_listeners('reordered') def __iadd__(self, other): - raise NotImplementedError() + index = len(self) + self = super(NotifyingList, self).__iadd__(other) + self._notify_listeners('items_inserted', index, other) + return self def __imul__(self, coefficient): - raise NotImplementedError() + index = len(self) + self = super(NotifyingList, self).__imul__(coefficient) + self._notify_listeners('items_inserted', index, self[index:]) + return self def __setslice__(self, i, j, sequence): raise NotImplementedError() |