add 'prepare()' step for post-processors
This allows post-processors to modify the destination path before checking if a file already exists.
This commit is contained in:
@@ -32,13 +32,18 @@ class ClassifyPP(PostProcessor):
|
||||
for ext in exts
|
||||
}
|
||||
|
||||
def run(self, pathfmt):
|
||||
def prepare(self, pathfmt):
|
||||
ext = pathfmt.keywords["extension"]
|
||||
|
||||
if ext in self.mapping:
|
||||
path = pathfmt.realdirectory + os.sep + self.mapping[ext]
|
||||
pathfmt.realpath = path + os.sep + pathfmt.filename
|
||||
os.makedirs(path, exist_ok=True)
|
||||
self._dir = pathfmt.realdirectory + os.sep + self.mapping[ext]
|
||||
pathfmt.realpath = self._dir + os.sep + pathfmt.filename
|
||||
else:
|
||||
self._dir = None
|
||||
|
||||
def run(self, pathfmt):
|
||||
if self._dir:
|
||||
os.makedirs(self._dir, exist_ok=True)
|
||||
|
||||
|
||||
__postprocessor__ = ClassifyPP
|
||||
|
||||
Reference in New Issue
Block a user