Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise exception if template has invalid variables #322

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ read_offset = 6 ; drive read offset in positive/negative frames (no leading +)
unknown = True
output_directory = ~/My Music
track_template = new/%%A/%%y - %%d/%%t - %%n ; note: the format char '%' must be represented '%%'
disc_template = %(track_template)s
disc_template = new/%%A/%%y - %%d/%%A - %%d
# ...
```

Expand Down
4 changes: 4 additions & 0 deletions whipper/common/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ def getPath(self, outdir, template, mbdiscid, metadata, track_number=None):
"""
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
Expand Down