diff options
Diffstat (limited to 'module/plugins')
-rw-r--r-- | module/plugins/Account.py | 4 | ||||
-rw-r--r-- | module/plugins/AccountManager.py | 2 | ||||
-rw-r--r-- | module/plugins/Base.py | 12 | ||||
-rw-r--r-- | module/plugins/Hook.py | 48 |
4 files changed, 42 insertions, 24 deletions
diff --git a/module/plugins/Account.py b/module/plugins/Account.py index dcf36f8a0..59ce87ed2 100644 --- a/module/plugins/Account.py +++ b/module/plugins/Account.py @@ -48,6 +48,10 @@ class Account(Base, AccountInfo): else: activated = Account.activated + for opt in self.known_opt: + if opt not in options: + options[opt] = "" + for opt in options.keys(): if opt not in self.known_opt: del options[opt] diff --git a/module/plugins/AccountManager.py b/module/plugins/AccountManager.py index 77139206c..00dd2ccc6 100644 --- a/module/plugins/AccountManager.py +++ b/module/plugins/AccountManager.py @@ -23,7 +23,7 @@ from random import choice from module.common.json_layer import json from module.utils import lock -class AccountManager(): +class AccountManager: """manages all accounts""" def __init__(self, core): diff --git a/module/plugins/Base.py b/module/plugins/Base.py index 0ad0d5caa..1477356ea 100644 --- a/module/plugins/Base.py +++ b/module/plugins/Base.py @@ -40,7 +40,7 @@ class Base(object): __pattern__ = r"" #: Config definition: list of (name, type, verbose_name, default_value) or #: (name, type, verbose_name, short_description, default_value) - __config__ = tuple() + __config__ = list() #: Short description, one liner __description__ = "" #: More detailed text @@ -68,9 +68,17 @@ class Base(object): self.log = core.log #: core config self.config = core.config + #: :class:`EventManager` + self.evm = core.eventManager + #: :class:`InteractionManager` + self.im = core.interActionManager - #log functions def logInfo(self, *args, **kwargs): + """ Print args to log at specific level + + :param args: Arbitary object which should be logged + :param kwargs: sep=(how to seperate arguments), default = " | " + """ self._log("info", *args, **kwargs) def logWarning(self, *args, **kwargs): diff --git a/module/plugins/Hook.py b/module/plugins/Hook.py index a3b86a794..fe464bdaa 100644 --- a/module/plugins/Hook.py +++ b/module/plugins/Hook.py @@ -14,8 +14,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>. - @author: mkaay - @interface-version: 0.2 + @author: RaNaN """ from traceback import print_exc @@ -24,11 +23,24 @@ from Base import Base class Expose(object): """ used for decoration to declare rpc services """ - def __new__(cls, f, *args, **kwargs): hookManager.addRPC(f.__module__, f.func_name, f.func_doc) return f +def AddEventListener(event): + """ used to register method for events """ + class _klass(object): + def __new__(cls, f, *args, **kwargs): + hookManager.addEventListener(f.__module__, f.func_name, event) + return f + return _klass + +class ConfigHandler(object): + """ register method as config handler """ + def __new__(cls, f, *args, **kwargs): + hookManager.addConfigHandler(f.__module__, f.func_name) + return f + def threaded(f): def run(*args,**kwargs): hookManager.startThread(f, *args, **kwargs) @@ -38,14 +50,6 @@ class Hook(Base): """ Base class for hook plugins. """ - __name__ = "Hook" - __version__ = "0.2" - __type__ = "hook" - __threaded__ = [] - __config__ = [ ("name", "type", "desc" , "default") ] - __description__ = """interface for hook""" - __author_name__ = ("mkaay", "RaNaN") - __author_mail__ = ("mkaay@mkaay.de", "RaNaN@pyload.org") #: automatically register event listeners for functions, attribute will be deleted dont use it yourself event_map = None @@ -108,7 +112,11 @@ class Hook(Base): def __repr__(self): return "<Hook %s>" % self.__name__ - + + def isActivated(self): + """ checks if hook is activated""" + return self.getConfig("activated") + def setup(self): """ more init stuff if needed """ pass @@ -116,11 +124,12 @@ class Hook(Base): def unload(self): """ called when hook was deactivated """ pass - - def isActivated(self): - """ checks if hook is activated""" - return self.config.get(self.__name__, "activated") - + + def deactivate(self): + pass + + def activate(self): + pass #event methods - overwrite these if needed def coreReady(self): @@ -134,10 +143,7 @@ class Hook(Base): def downloadFinished(self, pyfile): pass - - def downloadFailed(self, pyfile): - pass - + def packageFinished(self, pypack): pass |