X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fplugin.py;h=1188d4595e2190c47d8e6fbde7823926f49d852e;hb=78a694ddcd2a6ecc8b2b1fd3c74ee2d938707305;hp=e2764f96c849825a9d56a183b679aa51f86f7860;hpb=611f98994247324793027cae02d77e5a8efd0f42;p=mpd-sima.git diff --git a/sima/lib/plugin.py b/sima/lib/plugin.py index e2764f9..1188d45 100644 --- a/sima/lib/plugin.py +++ b/sima/lib/plugin.py @@ -1,6 +1,27 @@ # -*- coding: utf-8 -*- +# Copyright (c) 2013, 2014 Jack Kaliko +# +# This file is part of sima +# +# sima is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# sima is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with sima. If not, see . +# +# +""" +Plugin object to derive from +""" -class Plugin(): +class Plugin: """ First non-empty line of the docstring is used as description Rest of the docstring at your convenience. @@ -15,13 +36,17 @@ class Plugin(): def info(cls): """self documenting class method """ + doc = 'Undocumented plugin! Fill "{}" docstring'.format(cls.__name__) + if cls.__doc__: + doc = cls.__doc__.strip(' \n').splitlines()[0] return {'name': cls.__name__, - 'doc': cls.__doc__.strip(' \n').splitlines()[0] + 'doc': doc, } def __init__(self, daemon): self.log = daemon.log self.__daemon = daemon + self.player = daemon.player self.plugin_conf = None self.__get_config() @@ -34,14 +59,20 @@ class Plugin(): 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)) + self.plugin_conf = conf[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 @@ -59,12 +90,19 @@ class Plugin(): """ pass - def callback_need_song(self): + def callback_need_track(self): """Returns a list of Track objects to add """ pass + def callback_need_track_fb(self): + """Called when callback_next_song failled to find tracks to queue + Returns a list of Track objects to add + """ + pass + def shutdown(self): + """Called on application shutdown""" pass