merge #3675: [pixiv] fix --write-tags for '"tags": "original"'
This commit is contained in:
@@ -184,6 +184,13 @@ class MetadataPP(PostProcessor):
|
||||
for taglist in taglists:
|
||||
extend(taglist)
|
||||
tags.sort()
|
||||
elif all(isinstance(e, dict) for e in tags):
|
||||
taglists = tags
|
||||
tags = []
|
||||
extend = tags.extend
|
||||
for tagdict in taglists:
|
||||
extend([x for x in tagdict.values() if x is not None])
|
||||
tags.sort()
|
||||
|
||||
fp.write("\n".join(tags) + "\n")
|
||||
|
||||
|
||||
@@ -287,6 +287,18 @@ class MetadataTest(BasePostprocessorTest):
|
||||
self._trigger()
|
||||
self.assertEqual(self._output(m), "foobar1\nfoobar2\nfoobarbaz\n")
|
||||
|
||||
def test_metadata_tags_list_of_dict(self):
|
||||
self._create(
|
||||
{"mode": "tags"},
|
||||
{"tags": [
|
||||
{"g": "foobar1", "m": "foobar2"},
|
||||
{"g": None, "m": "foobarbaz"}
|
||||
]},
|
||||
)
|
||||
with patch("builtins.open", mock_open()) as m:
|
||||
self._trigger()
|
||||
self.assertEqual(self._output(m), "foobar1\nfoobar2\nfoobarbaz\n")
|
||||
|
||||
def test_metadata_custom(self):
|
||||
def test(pp_info):
|
||||
pp = self._create(pp_info, {"foo": "bar"})
|
||||
|
||||
Reference in New Issue
Block a user