mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
use Confit's as_str_seq() instead of get(list)
This validator lets the user write either a real list, like [a, b, c], or just a whitespace-separated string, like a b c. This is a little nicer for some settings like "plugins" where the brackets and commas just look like line noise.
This commit is contained in:
parent
2451571dbe
commit
a23b685747
6 changed files with 16 additions and 16 deletions
|
|
@ -48,7 +48,7 @@ def albums_in_dir(path):
|
|||
collapse_items = None
|
||||
|
||||
for root, dirs, files in sorted_walk(path,
|
||||
ignore=config['ignore'].get(list)):
|
||||
ignore=config['ignore'].as_str_seq()):
|
||||
# Get a list of items in the directory.
|
||||
items = []
|
||||
for filename in files:
|
||||
|
|
|
|||
|
|
@ -619,10 +619,10 @@ def _raw_main(args, load_config=True):
|
|||
from beets.ui.commands import default_commands
|
||||
|
||||
# Add plugin paths.
|
||||
for plugpath in config['pluginpath'].get(list):
|
||||
for plugpath in config['pluginpath'].as_str_seq():
|
||||
sys.path.append(os.path.expanduser(plugpath))
|
||||
# Load requested plugins.
|
||||
plugins.load_plugins(config['plugins'].get(list))
|
||||
plugins.load_plugins(config['plugins'].as_str_seq())
|
||||
plugins.send("pluginload")
|
||||
|
||||
# Construct the root parser.
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class IHatePlugin(BeetsPlugin):
|
|||
|
||||
def job_to_do(self):
|
||||
"""Return True if at least one pattern is defined."""
|
||||
return any(self.config[l].get(list) for l in
|
||||
return any(self.config[l].as_str_seq() for l in
|
||||
('warn_genre', 'warn_artist', 'warn_album',
|
||||
'skip_genre', 'skip_artist', 'skip_album'))
|
||||
|
||||
|
|
@ -103,19 +103,19 @@ class IHatePlugin(BeetsPlugin):
|
|||
if self.job_to_do():
|
||||
self._log.debug('[ihate] processing your hate')
|
||||
if self.do_i_hate_this(task,
|
||||
self.config['skip_genre'].get(list),
|
||||
self.config['skip_artist'].get(list),
|
||||
self.config['skip_album'].get(list),
|
||||
self.config['skip_whitelist'].get(list)):
|
||||
self.config['skip_genre'].as_str_seq(),
|
||||
self.config['skip_artist'].as_str_seq(),
|
||||
self.config['skip_album'].as_str_seq(),
|
||||
self.config['skip_whitelist'].as_str_seq()):
|
||||
task.choice_flag = action.SKIP
|
||||
self._log.info(u'[ihate] skipped: {0} - {1}'
|
||||
.format(task.cur_artist, task.cur_album))
|
||||
return
|
||||
if self.do_i_hate_this(task,
|
||||
self.config['warn_genre'].get(list),
|
||||
self.config['warn_artist'].get(list),
|
||||
self.config['warn_album'].get(list),
|
||||
self.config['warn_whitelist'].get(list)):
|
||||
self.config['warn_genre'].as_str_seq(),
|
||||
self.config['warn_artist'].as_str_seq(),
|
||||
self.config['warn_album'].as_str_seq(),
|
||||
self.config['warn_whitelist'].as_str_seq()):
|
||||
self._log.info(u'[ihate] you maybe hate this: {0} - {1}'
|
||||
.format(task.cur_artist, task.cur_album))
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ def _record_items(lib, basename, items):
|
|||
"""Records relative paths to the given items for each feed format
|
||||
"""
|
||||
feedsdir = config['importfeeds']['dir'].as_filename()
|
||||
formats = config['importfeeds']['formats'].get(list)
|
||||
formats = config['importfeeds']['formats'].as_str_seq()
|
||||
|
||||
paths = []
|
||||
for item in items:
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class ThePlugin(BeetsPlugin):
|
|||
'patterns': [],
|
||||
})
|
||||
|
||||
self.patterns = self.config['patterns'].get(list)
|
||||
self.patterns = self.config['patterns'].as_str_seq()
|
||||
for p in self.patterns:
|
||||
if p:
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -47,13 +47,13 @@ class ZeroPlugin(BeetsPlugin):
|
|||
self.patterns = {}
|
||||
self.warned = False
|
||||
|
||||
for f in self.config['fields'].get(list):
|
||||
for f in self.config['fields'].as_str_seq():
|
||||
if f not in ITEM_KEYS:
|
||||
self._log.error(u'[zero] invalid field: {0}'.format(f))
|
||||
else:
|
||||
self.fields.append(f)
|
||||
try:
|
||||
self.patterns[f] = self.config[f].get(list)
|
||||
self.patterns[f] = self.config[f].as_str_seq()
|
||||
except confit.NotFoundError:
|
||||
self.patterns[f] = [u'']
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue