X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fplugin.py;h=999255f956ce0ff6e0c23ab8230a38129aaf7cc6;hb=c1bda032095902bdcd183c530a9c4de28f3c828a;hp=f846e2e9d16565244f7178d32cede6edaa3da49a;hpb=5fe20b6caffe162afe5be18e77fe40004d00c95e;p=mpd-sima.git diff --git a/sima/lib/plugin.py b/sima/lib/plugin.py index f846e2e..999255f 100644 --- a/sima/lib/plugin.py +++ b/sima/lib/plugin.py @@ -1,18 +1,53 @@ # -*- coding: utf-8 -*- class Plugin(): + """ + First non-empty line of the docstring is used as description + Rest of the docstring at your convenience. + + The plugin Name MUST be the same as the module (file name), case + insensitive: for instance plugin.py → Plugin + It eases plugins discovery and simplifies the code to handle them, + IMHO, it's a fair trade-off. + """ + + @classmethod + def info(cls): + """self documenting class method + """ + return {'name': cls.__name__, + 'doc': cls.__doc__.strip(' \n').splitlines()[0] + } + def __init__(self, daemon): self.log = daemon.log self.__daemon = daemon - #self.history = daemon.player.history + self.plugin_conf = None + self.__get_config() + + def __str__(self): + return self.__class__.__name__ - @property - def name(self): - return self.__class__.__name__.lower() + def __get_config(self): + """Get plugin's specific configuration from global applications's config + """ + conf = self.__daemon.config + for sec in conf.sections(): + if sec.lower() == self.__class__.__name__.lower(): + self.plugin_conf = dict(conf.items(sec)) + #if self.plugin_conf: + # self.log.debug('Got config for {0}: {1}'.format(self, + # self.plugin_conf)) def callback_player(self): """ - Called on player changes + Called on player changes, stopped, paused, skipped + """ + pass + + def callback_player_database(self): + """ + Called on player music library changes """ pass @@ -26,11 +61,11 @@ class Plugin(): def callback_next_song(self): """Not returning data, - Could be use to scrobble + Could be use to scrobble, maintain an history… """ pass - def callback_need_song(self): + def callback_need_track(self): """Returns a list of Track objects to add """ pass