Merge pull request #499 from geigerzaehler/master

Make pluginpath configuration useable
This commit is contained in:
Adrian Sampson 2014-01-20 18:55:20 -08:00
commit 28d4b9320c
4 changed files with 27 additions and 5 deletions

View file

@ -746,7 +746,12 @@ def _raw_main(args):
from beets.ui.commands import default_commands
# Add plugin paths.
import beetsplug
beetsplug.__path__ = get_plugin_paths() + beetsplug.__path__
# For backwards compatibility
sys.path += get_plugin_paths()
# Load requested plugins.
plugins.load_plugins(config['plugins'].as_str_seq())
plugins.send("pluginload")

View file

@ -55,11 +55,11 @@ includes the BPD plugin for playing music.
pluginpath
~~~~~~~~~~
Directories to search for plugins. These paths are just added to ``sys.path``
before the plugins are loaded. (The plugins still have to be contained in a
``beetsplug`` namespace package.) This can either be a single string or a list
of strings---so, if you have multiple paths, format them as a YAML list like
so::
Directories to search for plugins. Each Python file or directory in a plugin
path represents a plugin and should define a subclass of :class:`BeetsPlugin`.
A plugin can then be loaded by adding the filename to the `plugins` configuration.
The plugin path can either be a single string or a list of strings---so, if you
have multiple paths, format them as a YAML list like so::
pluginpath:
- /path/one

View file

@ -0,0 +1,11 @@
from beets.plugins import BeetsPlugin
from beets import ui
class TestPlugin(BeetsPlugin):
def __init__(self):
super(TestPlugin, self).__init__()
def commands(self):
cmd = ui.Subcommand('test')
cmd.func = lambda *args: None
return [cmd]

View file

@ -666,6 +666,12 @@ class PathFormatTest(_common.TestCase):
self.assertEqual(tmpl.original, 'bar')
self.assertEqual(pf[1:], default_formats)
class PluginTest(_common.TestCase):
def test_plugin_command_from_pluginpath(self):
config['pluginpath'] = [os.path.join(_common.RSRC, 'beetsplug')]
config['plugins'] = ['test']
ui._raw_main(['test'])
def suite():
return unittest.TestLoader().loadTestsFromName(__name__)