[postprocessor:metadata] add 'skip' option (#3786)

This commit is contained in:
Mike Fährmann
2023-03-17 23:16:52 +01:00
parent 2bb937014f
commit 00f0233b28
3 changed files with 49 additions and 0 deletions

View File

@@ -87,6 +87,7 @@ class MetadataPP(PostProcessor):
self.omode = options.get("open", omode)
self.encoding = options.get("encoding", "utf-8")
self.private = options.get("private", False)
self.skip = options.get("skip", False)
def run(self, pathfmt):
archive = self.archive
@@ -96,6 +97,9 @@ class MetadataPP(PostProcessor):
directory = self._directory(pathfmt)
path = directory + self._filename(pathfmt)
if self.skip and os.path.exists(path):
return
try:
with open(path, self.omode, encoding=self.encoding) as fp:
self.write(fp, pathfmt.kwdict)