support 'filter' option for post processors (#1460)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018-2020 Mike Fährmann
|
||||
# Copyright 2018-2021 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
|
||||
@@ -31,9 +31,8 @@ class ClassifyPP(PostProcessor):
|
||||
for directory, exts in mapping.items()
|
||||
for ext in exts
|
||||
}
|
||||
|
||||
job.hooks["prepare"].append(self.prepare)
|
||||
job.hooks["file"].append(self.move)
|
||||
job.register_hooks(
|
||||
{"prepare": self.prepare, "file": self.move}, options)
|
||||
|
||||
def prepare(self, pathfmt):
|
||||
ext = pathfmt.extension
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2020 Mike Fährmann
|
||||
# Copyright 2020-2021 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
|
||||
@@ -18,11 +18,12 @@ class ComparePP(PostProcessor):
|
||||
PostProcessor.__init__(self, job)
|
||||
if options.get("shallow"):
|
||||
self._compare = self._compare_size
|
||||
job.hooks["file"].append(
|
||||
|
||||
job.register_hooks({"file": (
|
||||
self.enumerate
|
||||
if options.get("action") == "enumerate" else
|
||||
self.compare
|
||||
)
|
||||
)}, options)
|
||||
|
||||
def compare(self, pathfmt):
|
||||
try:
|
||||
|
||||
@@ -41,8 +41,7 @@ class ExecPP(PostProcessor):
|
||||
events = ("after",)
|
||||
elif isinstance(events, str):
|
||||
events = events.split(",")
|
||||
for event in events:
|
||||
job.hooks[event].append(execute)
|
||||
job.register_hooks({event: execute for event in events}, options)
|
||||
|
||||
def exec_list(self, pathfmt, status=None):
|
||||
if status:
|
||||
|
||||
@@ -57,8 +57,7 @@ class MetadataPP(PostProcessor):
|
||||
events = ("file",)
|
||||
elif isinstance(events, str):
|
||||
events = events.split(",")
|
||||
for event in events:
|
||||
job.hooks[event].append(self.run)
|
||||
job.register_hooks({event: self.run for event in events}, options)
|
||||
|
||||
def run(self, pathfmt):
|
||||
directory = self._directory(pathfmt)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2019-2020 Mike Fährmann
|
||||
# Copyright 2019-2021 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
|
||||
@@ -17,7 +17,7 @@ class MtimePP(PostProcessor):
|
||||
def __init__(self, job, options):
|
||||
PostProcessor.__init__(self, job)
|
||||
self.key = options.get("key", "date")
|
||||
job.hooks["file"].append(self.run)
|
||||
job.register_hooks({"file": self.run}, options)
|
||||
|
||||
def run(self, pathfmt):
|
||||
mtime = pathfmt.kwdict.get(self.key)
|
||||
|
||||
@@ -55,8 +55,8 @@ class UgoiraPP(PostProcessor):
|
||||
else:
|
||||
self.prevent_odd = False
|
||||
|
||||
job.hooks["prepare"].append(self.prepare)
|
||||
job.hooks["file"].append(self.convert)
|
||||
job.register_hooks(
|
||||
{"prepare": self.prepare, "file": self.convert}, options)
|
||||
|
||||
def prepare(self, pathfmt):
|
||||
self._frames = None
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018-2020 Mike Fährmann
|
||||
# Copyright 2018-2021 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
|
||||
@@ -38,9 +38,11 @@ class ZipPP(PostProcessor):
|
||||
self.args = (self.path[:-1] + ext, "a",
|
||||
self.COMPRESSION_ALGORITHMS[algorithm], True)
|
||||
|
||||
job.hooks["file"].append(
|
||||
self.write_safe if options.get("mode") == "safe" else self.write)
|
||||
job.hooks["finalize"].append(self.finalize)
|
||||
job.register_hooks({
|
||||
"file":
|
||||
self.write_safe if options.get("mode") == "safe" else self.write,
|
||||
"finalize": self.finalize,
|
||||
}, options)
|
||||
|
||||
def write(self, pathfmt, zfile=None):
|
||||
# 'NameToInfo' is not officially documented, but it's available
|
||||
|
||||
Reference in New Issue
Block a user