diff options
author | Martin Sivak <msivak@redhat.com> | 2008-04-21 15:14:57 +0200 |
---|---|---|
committer | Martin Sivak <msivak@redhat.com> | 2008-04-21 15:14:57 +0200 |
commit | be9ed347828b94aa6a8f7c097b34a74cbd882891 (patch) | |
tree | 0ec33ec7702d83b4ab68ba91c8abee028600a863 /pyfirstaidkit | |
parent | ddbadfc4ad83f8372b495a30aea8ae4e5cc78bf2 (diff) | |
download | firstaidkit-be9ed347828b94aa6a8f7c097b34a74cbd882891.tar.gz firstaidkit-be9ed347828b94aa6a8f7c097b34a74cbd882891.tar.xz firstaidkit-be9ed347828b94aa6a8f7c097b34a74cbd882891.zip |
Improvements targeted at better Gui integration
Diffstat (limited to 'pyfirstaidkit')
-rw-r--r-- | pyfirstaidkit/interpret.py | 29 | ||||
-rw-r--r-- | pyfirstaidkit/reporting.py | 10 |
2 files changed, 29 insertions, 10 deletions
diff --git a/pyfirstaidkit/interpret.py b/pyfirstaidkit/interpret.py index 35b0f44..4a920da 100644 --- a/pyfirstaidkit/interpret.py +++ b/pyfirstaidkit/interpret.py @@ -31,12 +31,31 @@ class Tasker: name = "Task interpreter" - def __init__(self, cfg): - self._provide = Dependencies() + def __init__(self, cfg, reporting = None, dependencies = None, backups = None, pluginsystem = None): self._config = cfg - self._reporting = Reports() - self._backups = FileBackupStore(cfg.backup.path) - self.pluginSystem = PluginSystem(reporting = self._reporting, dependencies = self._provide, backups = self._backups) + + if dependencies is None: + self._provide = Dependencies() + else: + self._provide = dependencies + + if reporting is None: + self._reporting = Reports() + else: + self._reporting = reporting + + if backups is None: + self._backups = FileBackupStore(cfg.backup.path) + else: + self._backups = backups + + if pluginsystem is None: + self.pluginSystem = PluginSystem(reporting = self._reporting, dependencies = self._provide, backups = self._backups) + else: + self.pluginSystem = pluginsystem + + def flags(self): + return self._provide def reporting(self): return self._reporting diff --git a/pyfirstaidkit/reporting.py b/pyfirstaidkit/reporting.py index eefc88c..98018f7 100644 --- a/pyfirstaidkit/reporting.py +++ b/pyfirstaidkit/reporting.py @@ -77,10 +77,10 @@ class Reports(object): self._mailboxes = [] self._notify = [] - def notify(self, cb, data): + def notify(self, cb, *args, **kwargs): """When putting anything new into the Queue, run notifications callbacks. Usefull for Gui and single-thread reporting. - The notification function has two parameters: data passed when registering callback, message recorded to the queue""" - return self._notify.append((cb, data)) + The notification function has parameters: message recorded to the queue, any parameters provided when registering""" + return self._notify.append((cb, args, kwargs)) def put(self, message, level, origin, action, importance = logging.INFO, reply = None, title = "", destination = None): data = {"level": level, "origin": origin, "action": action, "importance": importance, "message": message, "reply": reply, "title": title} @@ -98,8 +98,8 @@ class Reports(object): ret=destination.put(data) #call all the notify callbacks - for func, regdata in self._notify: - func(regdata, data) + for func, args, kwargs in self._notify: + func(data, *args, **kwargs) return ret |