[postprocessor:metadata] assume 'mode: custom' when format is set
{"name": "metadata", "format": "foobar"}
will now implicitly use mode:custom and no longer mode:json like before
This commit is contained in:
@@ -20,14 +20,8 @@ class MetadataPP(PostProcessor):
|
|||||||
PostProcessor.__init__(self, job)
|
PostProcessor.__init__(self, job)
|
||||||
|
|
||||||
mode = options.get("mode", "json")
|
mode = options.get("mode", "json")
|
||||||
if mode == "custom":
|
cfmt = options.get("content-format") or options.get("format")
|
||||||
self.write = self._write_custom
|
if mode == "tags":
|
||||||
cfmt = options.get("content-format") or options.get("format")
|
|
||||||
if isinstance(cfmt, list):
|
|
||||||
cfmt = "\n".join(cfmt) + "\n"
|
|
||||||
self._content_fmt = formatter.parse(cfmt).format_map
|
|
||||||
ext = "txt"
|
|
||||||
elif mode == "tags":
|
|
||||||
self.write = self._write_tags
|
self.write = self._write_tags
|
||||||
ext = "txt"
|
ext = "txt"
|
||||||
elif mode == "modify":
|
elif mode == "modify":
|
||||||
@@ -41,6 +35,12 @@ class MetadataPP(PostProcessor):
|
|||||||
self.run = self._run_delete
|
self.run = self._run_delete
|
||||||
self.fields = options.get("fields")
|
self.fields = options.get("fields")
|
||||||
ext = None
|
ext = None
|
||||||
|
elif mode == "custom" or cfmt:
|
||||||
|
self.write = self._write_custom
|
||||||
|
if isinstance(cfmt, list):
|
||||||
|
cfmt = "\n".join(cfmt) + "\n"
|
||||||
|
self._content_fmt = formatter.parse(cfmt).format_map
|
||||||
|
ext = "txt"
|
||||||
else:
|
else:
|
||||||
self.write = self._write_json
|
self.write = self._write_json
|
||||||
self.indent = options.get("indent", 4)
|
self.indent = options.get("indent", 4)
|
||||||
|
|||||||
@@ -267,6 +267,7 @@ class MetadataTest(BasePostprocessorTest):
|
|||||||
test({"mode": "custom", "content-format": "{foo}\n{missing}\n"})
|
test({"mode": "custom", "content-format": "{foo}\n{missing}\n"})
|
||||||
test({"mode": "custom", "content-format": ["{foo}", "{missing}"]})
|
test({"mode": "custom", "content-format": ["{foo}", "{missing}"]})
|
||||||
test({"mode": "custom", "format": "{foo}\n{missing}\n"})
|
test({"mode": "custom", "format": "{foo}\n{missing}\n"})
|
||||||
|
test({"format": "{foo}\n{missing}\n"})
|
||||||
|
|
||||||
def test_metadata_extfmt(self):
|
def test_metadata_extfmt(self):
|
||||||
pp = self._create({
|
pp = self._create({
|
||||||
|
|||||||
Reference in New Issue
Block a user