From 8189c1ee21be899f090eef7211c12e10a11a9f53 Mon Sep 17 00:00:00 2001 From: Olivier Tilloy Date: Mon, 4 May 2009 09:55:38 +0200 Subject: NotifyingList: implementation of reverse, sort, __iadd__, __imul__. --- src/pyexiv2.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src') 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() -- cgit