1
0
Fork 0

Ability to set a specific field in the file's metadata

Eg: `--parse-metadata "description:(?s)(?P<meta_comment>.+)"`
sets the "comment" field using `description`
This commit is contained in:
pukkandan 2021-04-03 13:59:55 +05:30
commit 84601bb72b
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698
3 changed files with 12 additions and 6 deletions

View file

@ -45,7 +45,7 @@ class MetadataFromFieldPP(PostProcessor):
# replace %(..)s with regex group and escape other string parts
for match in re.finditer(r'%\((\w+)\)s', fmt):
regex += re.escape(fmt[lastpos:match.start()])
regex += r'(?P<%s>[^\r\n]+)' % match.group(1)
regex += r'(?P<%s>.+)' % match.group(1)
lastpos = match.end()
if lastpos < len(fmt):
regex += re.escape(fmt[lastpos:])