merge 'bypost' functionality into metadata postprocessor

This commit is contained in:
Mike Fährmann
2019-12-16 17:19:23 +01:00
parent c0b9ad678d
commit 63e6993716
6 changed files with 29 additions and 54 deletions

View File

@@ -18,7 +18,6 @@ modules = [
"mtime",
"ugoira",
"zip",
"metadata_bypost",
]
log = logging.getLogger("postprocessor")

View File

@@ -26,6 +26,10 @@ class PostProcessor():
def run(pathfmt):
"""Execute the postprocessor for a file"""
@staticmethod
def run_metadata(pathfmt):
"""Execute the postprocessor for a file"""
@staticmethod
def run_after(pathfmt):
"""Execute postprocessor after moving a file to its target location"""

View File

@@ -40,6 +40,9 @@ class MetadataPP(PostProcessor):
self.path = self._path_append
self.extension = options.get("extension", ext)
if options.get("bypost"):
self.run_metadata, self.run = self.run, self.run_metadata
def run(self, pathfmt):
with open(self.path(pathfmt), "w", encoding="utf-8") as file:
self.write(file, pathfmt.kwdict)

View File

@@ -1,27 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
"""Write metadata to JSON files"""
from .metadata import __postprocessor__ as MetadataPP
class Metadata_bypostPP(MetadataPP):
def __init__(self, pathfmt, options):
MetadataPP.__init__(self, pathfmt, options)
def prepare(self, pathfmt):
# Only run this processor on metadata messages, not individual images.
if pathfmt.kwdict.get("metadata_only"):
MetadataPP.run(self, pathfmt)
def run(self, pathfmt):
return
__postprocessor__ = Metadata_bypostPP