summaryrefslogtreecommitdiffstats
path: root/gallery_dl/postprocessor/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'gallery_dl/postprocessor/__init__.py')
-rw-r--r--gallery_dl/postprocessor/__init__.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/gallery_dl/postprocessor/__init__.py b/gallery_dl/postprocessor/__init__.py
new file mode 100644
index 0000000..093f8e0
--- /dev/null
+++ b/gallery_dl/postprocessor/__init__.py
@@ -0,0 +1,44 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2018-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.
+
+"""Post-processing modules"""
+
+import importlib
+import logging
+
+modules = [
+ "classify",
+ "exec",
+ "metadata",
+ "ugoira",
+ "zip",
+]
+
+log = logging.getLogger("postprocessor")
+
+
+def find(name):
+ """Return a postprocessor class with the given name"""
+ try:
+ return _cache[name]
+ except KeyError:
+ klass = None
+ try:
+ if name in modules: # prevent unwanted imports
+ module = importlib.import_module("." + name, __package__)
+ klass = module.__postprocessor__
+ except (ImportError, AttributeError, TypeError):
+ pass
+ _cache[name] = klass
+ return klass
+
+
+# --------------------------------------------------------------------
+# internals
+
+_cache = {}