X-Git-Url: http://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Fplugin.py;h=0523a75f2513e723b692dc77829d651336d77220;hb=e9ed5c171c9251ef6ae7765b1406e2f5b2cb1c0d;hp=cea4448346749c582e91944623712978ff5f595b;hpb=c660efb577c11bde6229d37550bf197fa6bae3e4;p=mpd-sima.git diff --git a/sima/lib/plugin.py b/sima/lib/plugin.py index cea4448..0523a75 100644 --- a/sima/lib/plugin.py +++ b/sima/lib/plugin.py @@ -1,12 +1,33 @@ # -*- coding: utf-8 -*- - -class Plugin(): +# 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: """ 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 + The lowercased plugin Name MUST be the same as the module (file name), + for instance Plugin → plugin.py It eases plugins discovery and simplifies the code to handle them, IMHO, it's a fair trade-off. """ @@ -37,12 +58,19 @@ 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 sec == self.__class__.__name__.lower(): + self.plugin_conf = conf[sec] #if self.plugin_conf: # self.log.debug('Got config for {0}: {1}'.format(self, # self.plugin_conf)) + def start(self): + """ + Called when the daemon().run() is called and + right after the player has connected successfully. + """ + pass + def callback_player(self): """ Called on player changes, stopped, paused, skipped @@ -81,6 +109,7 @@ class Plugin(): pass def shutdown(self): + """Called on application shutdown""" pass