Skip to content

Commit

Permalink
[postprocessor:metadata] support putting keys in quotes
Browse files Browse the repository at this point in the history
for mode 'modify' and 'delete'
based on fe41a2b
  • Loading branch information
mikf committed Apr 25, 2023
1 parent 7459e4a commit 3905f05
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions gallery_dl/postprocessor/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ def _traverse(obj, key):

while "[" in key:
name, _, key = key.partition("[")
obj = obj[name.rstrip("]")]
obj = obj[name.strip("\"']")]

return obj, key.strip("]")
return obj, key.strip("\"']")


__postprocessor__ = MetadataPP
12 changes: 6 additions & 6 deletions test/test_postprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,11 @@ def test_metadata_modify(self):
self._create({
"mode": "modify",
"fields": {
"foo" : "{filename}-{foo!s}",
"foo2" : "\fE bar['bax'] + 122",
"bar[baz]" : "{_now}",
"bar[ba2]" : "\fE {}",
"bar[ba2][a]": "test",
"foo" : "{filename}-{foo!s}",
"foo2" : "\fE bar['bax'] + 122",
"bar['baz']" : "{_now}",
"bar[\"ba2\"]" : "\fE {}",
"bar['ba2'][a]": "test",
},
}, kwdict)

Expand All @@ -423,7 +423,7 @@ def test_metadata_delete(self):
}
self._create({
"mode": "delete",
"fields": ["foo", "bar[bax]", "bar[baz][a]"],
"fields": ["foo", "bar['bax']", "bar[\"baz\"][a]"],
}, kwdict)

pdict = self.pathfmt.kwdict
Expand Down

0 comments on commit 3905f05

Please sign in to comment.