made OneShotObserverList a new-style class

This commit is contained in:
tpltnt 2019-05-11 17:58:39 +02:00
parent c8f11dc2d3
commit 4c2f0db5d2

View File

@ -10,7 +10,7 @@ something happens. The way this is typically implemented is that the observed
has an ObserverList whose when_fired method is called in the observed's
'when_something'."""
class OneShotObserverList:
class OneShotObserverList(object):
"""A one-shot event distributor."""
def __init__(self):
self._fired = False
@ -18,6 +18,12 @@ class OneShotObserverList:
self._watchers = []
self.__repr__ = self._unfired_repr
def __repr__(self):
"""string representation of the OneshotObserverList"""
if self._fired:
return self._fired_repr()
return self._unfired_repr()
def _unfired_repr(self):
return "<OneShotObserverList [%s]>" % (self._watchers, )