From 938b7e6141e2895c7d41b0e8ef4b9416912e2e9e Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Apr 2015 17:28:58 +0200 Subject: Spare code cosmetics (4) --- docs/write_addons.rst | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'docs/write_addons.rst') diff --git a/docs/write_addons.rst b/docs/write_addons.rst index 9f4436cc5..cc39ab259 100644 --- a/docs/write_addons.rst +++ b/docs/write_addons.rst @@ -18,6 +18,7 @@ All addons should start with something like this: :: from pyload.plugin.Addon import Addon + class YourAddon(Addon): __name = "YourAddon" __version = "0.1" @@ -53,6 +54,7 @@ A basic excerpt would look like: :: from pyload.plugin.Addon import Addon + class YourAddon(Addon): """ Your Addon code here. @@ -73,6 +75,7 @@ It requires a `dict` that maps event names to function names or a `list` of func from pyload.plugin.Addon import Addon + class YourAddon(Addon): """ Your Addon code here. @@ -109,6 +112,7 @@ Sounds complicated but is very easy to do. Just use the ``Expose`` decorator: :: from pyload.plugin.Addon import Addon, Expose + class YourAddon(Addon): """ Your Addon code here. @@ -134,6 +138,7 @@ Just store everything in ``self.info``. :: from pyload.plugin.Addon import Addon + class YourAddon(Addon): """ Your Addon code here. -- cgit v1.2.3 From bb5a115533711fd8bb87f53cb32ff7342137208d Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 18 Apr 2015 00:29:55 +0200 Subject: Spare code cosmetics (5) --- docs/write_addons.rst | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'docs/write_addons.rst') diff --git a/docs/write_addons.rst b/docs/write_addons.rst index cc39ab259..b7f6dfdb8 100644 --- a/docs/write_addons.rst +++ b/docs/write_addons.rst @@ -63,6 +63,7 @@ A basic excerpt would look like: :: def activate(self): print "Yay, the core is ready let's do some work." + def downloadFinished(self, pyfile): print "A Download just finished." @@ -80,16 +81,20 @@ It requires a `dict` that maps event names to function names or a `list` of func """ Your Addon code here. """ + event_map = {'downloadFinished': "doSomeWork", 'allDownloadsFnished': "someMethod", 'activate': "initialize"} + def initialize(self): print "Initialized." + def doSomeWork(self, pyfile): print "This is equivalent to the above example." + def someMethod(self): print "The underlying event (allDownloadsFinished) for this method is not available through the base class" @@ -147,6 +152,7 @@ Just store everything in ``self.info``. :: def setup(self): self.info = {'running': False} + def activate(self): self.info['running'] = True -- cgit v1.2.3