fix plugin errors with missing sections

This commit is contained in:
Adrian Sampson 2012-01-31 18:52:27 -08:00
parent cd63be80ba
commit 74f14a7aeb
3 changed files with 10 additions and 5 deletions

View file

@ -59,8 +59,9 @@ class InlinePlugin(BeetsPlugin):
cls = type(self)
# Add field expressions.
for key, value in config.items('pathfields', True):
log.debug(u'adding template field %s' % key)
func = compile_expr(value)
if func is not None:
cls.template_fields[key] = func
if config.has_section('pathfields'):
for key, value in config.items('pathfields', True):
log.debug(u'adding template field %s' % key)
func = compile_expr(value)
if func is not None:
cls.template_fields[key] = func

View file

@ -48,6 +48,8 @@ class RewritePlugin(BeetsPlugin):
# Gather all the rewrite rules for each field.
rules = defaultdict(list)
if not config.has_section('rewrite'):
return
for key, value in config.items('rewrite', True):
try:
fieldname, pattern = key.split(None, 1)

View file

@ -32,6 +32,8 @@ Changelog
recording associated with a fingerprint.
* Fix a crash when an autotagging with an artist or album containing "AND" or
"OR" (upper case).
* Fix an error in the ``rewrite`` and ``inline`` plugins when the corresponding
config sections did not exist.
1.0b12 (January 16, 2012)
-------------------------