mirror of
https://github.com/beetbox/beets.git
synced 2025-12-27 11:02:43 +01:00
correctly parse and migrate "pluginpath"
This used to be a colon-separated list. Now we use a real YAML list (or a single string).
This commit is contained in:
parent
cf3860257f
commit
3e2aca82b8
3 changed files with 28 additions and 5 deletions
|
|
@ -431,6 +431,20 @@ def get_replacements():
|
|||
))
|
||||
return replacements
|
||||
|
||||
def get_plugin_paths():
|
||||
"""Get the list of search paths for plugins from the config file.
|
||||
The value for "pluginpath" may be a single string or a list of
|
||||
strings.
|
||||
"""
|
||||
pluginpaths = config['pluginpath'].get()
|
||||
if isinstance(pluginpaths, basestring):
|
||||
pluginpaths = [pluginpaths]
|
||||
if not isinstance(pluginpaths, list):
|
||||
raise confit.ConfigTypeError(
|
||||
u'pluginpath must be string or a list of strings'
|
||||
)
|
||||
return map(util.normpath, pluginpaths)
|
||||
|
||||
def _pick_format(album, fmt=None):
|
||||
"""Pick a format string for printing Album or Item objects,
|
||||
falling back to config options and defaults.
|
||||
|
|
@ -640,8 +654,7 @@ def _raw_main(args, load_config=True):
|
|||
from beets.ui.commands import default_commands
|
||||
|
||||
# Add plugin paths.
|
||||
for plugpath in config['pluginpath'].as_str_seq():
|
||||
sys.path.append(os.path.expanduser(plugpath))
|
||||
sys.path += get_plugin_paths()
|
||||
# Load requested plugins.
|
||||
plugins.load_plugins(config['plugins'].as_str_seq())
|
||||
plugins.send("pluginload")
|
||||
|
|
|
|||
|
|
@ -184,6 +184,10 @@ def transform_data(data):
|
|||
replacements[pat] = repl
|
||||
out['replace'] = replacements
|
||||
|
||||
elif key == 'pluginpath':
|
||||
# Used to be a colon-separated string. Now a list.
|
||||
out['pluginpath'] = value.split(':')
|
||||
|
||||
else:
|
||||
out[key] = value
|
||||
|
||||
|
|
|
|||
|
|
@ -54,9 +54,15 @@ includes the BPD plugin for playing music.
|
|||
pluginpath
|
||||
~~~~~~~~~~
|
||||
|
||||
A colon-separated list of 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.
|
||||
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::
|
||||
|
||||
pluginpath:
|
||||
- /path/one
|
||||
- /path/two
|
||||
|
||||
ignore
|
||||
~~~~~~
|
||||
|
|
|
|||
Loading…
Reference in a new issue