diff options
author | Walter Purcaro <vuolter@gmail.com> | 2013-06-05 12:17:07 +0200 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2013-07-07 09:06:27 +0200 |
commit | dddf2b822953a96e2b91cca49e69adc064b4fef7 (patch) | |
tree | d2323bd82dcb9da1d64f0f7ec468ea8ee407b80d | |
parent | Version 1.06: code cosmetics (diff) | |
download | pyload-dddf2b822953a96e2b91cca49e69adc064b4fef7.tar.xz |
Version 1.07: improved event managing
-rw-r--r-- | module/plugins/hooks/DeleteFinished.py | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/module/plugins/hooks/DeleteFinished.py b/module/plugins/hooks/DeleteFinished.py index 5947f481a..5c1db397c 100644 --- a/module/plugins/hooks/DeleteFinished.py +++ b/module/plugins/hooks/DeleteFinished.py @@ -23,7 +23,7 @@ from module.plugins.Hook import Hook class DeleteFinished(Hook): __name__ = "DeleteFinished" - __version__ = "1.06" + __version__ = "1.07" __description__ = "Automatically delete all finished packages from queue" __config__ = [ ("activated", "bool", "Activated", "False"), @@ -69,19 +69,15 @@ class DeleteFinished(Hook): self.info["sleep"] = False ## event managing ## - def addEvent(self, event, handler): - if event in self.manager.events: - if handler not in self.manager.events[event]: - self.manager.events[event].append(handler) + def addEvent(self, event, func): + """Adds an event listener for event name""" + if event in self.events: + if func in self.events[event]: + self.logDebug("Function already registered %s" % func) else: - return False + self.events[event].append(func) else: - self.manager.events[event] = [handler] - return True + self.events[event] = [func] - def removeEvent(self, event, handler): - if event in self.manager.events and handler in self.manager.events[event]: - self.manager.events[event].remove(handler) - return True - else: - return False + def setup(self): + self.removeEvent = self.manager.removeEvent |