summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@gmail.com> 2013-06-05 12:17:07 +0200
committerGravatar Walter Purcaro <vuolter@gmail.com> 2013-07-07 09:06:27 +0200
commitdddf2b822953a96e2b91cca49e69adc064b4fef7 (patch)
treed2323bd82dcb9da1d64f0f7ec468ea8ee407b80d
parentVersion 1.06: code cosmetics (diff)
downloadpyload-dddf2b822953a96e2b91cca49e69adc064b4fef7.tar.xz
Version 1.07: improved event managing
-rw-r--r--module/plugins/hooks/DeleteFinished.py24
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