Fix setting None metadata from FILENAME_METADATA matches.

This is relevant when using optional items in the expression. E.g. if an
optional captured group is not matched, the result of
`match.groupdict()` contains the captured group with value `None`.
This commit is contained in:
Tim Wienk 2017-03-11 13:38:54 +01:00
commit 4917b8618a
2 changed files with 39 additions and 1 deletions

View file

@ -672,7 +672,7 @@ def parse_path_metadata(source_path, settings=None, process=None):
# .items() for py3k compat.
for k, v in match.groupdict().items():
k = k.lower() # metadata must be lowercase
if k not in metadata:
if v is not None and k not in metadata:
if process:
v = process(k, v)
metadata[k] = v