Raise exception if template has invalid variables
If the template string contains variables which aren't valid for whipper, raise ValueError exception listing all the included unrecognized variables. I've also corrected the example template configuration lines in the README. Fixes #279.
This commit is contained in:
@@ -196,6 +196,10 @@ class Program:
|
||||
"""
|
||||
assert isinstance(outdir, unicode), "%r is not unicode" % outdir
|
||||
assert isinstance(template, unicode), "%r is not unicode" % template
|
||||
matches = re.findall(r"%[^A,S,d,y,r,R,x,X]", template)
|
||||
if '%' in template and matches:
|
||||
raise ValueError('disc template string contains invalid '
|
||||
'variable(s): {}.'.format(', '.join(matches)))
|
||||
v = {}
|
||||
v['A'] = 'Unknown Artist'
|
||||
v['d'] = mbdiscid # fallback for title
|
||||
|
||||
Reference in New Issue
Block a user