mirror of
https://github.com/beetbox/beets.git
synced 2026-02-22 23:33:50 +01:00
Merge pull request #499 from geigerzaehler/master
Make pluginpath configuration useable
This commit is contained in:
commit
28d4b9320c
4 changed files with 27 additions and 5 deletions
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
11
test/rsrc/beetsplug/test.py
Normal file
11
test/rsrc/beetsplug/test.py
Normal 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]
|
||||
|
|
@ -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__)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue