2018-05-20 22:03:57 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-04-16 18:09:30 +02:00
|
|
|
# Copyright 2018-2019 Mike Fährmann
|
2018-05-20 22:03:57 +02:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2018-09-04 22:49:57 +02:00
|
|
|
"""Post-processing modules"""
|
|
|
|
|
2018-05-20 22:03:57 +02:00
|
|
|
import importlib
|
|
|
|
import logging
|
|
|
|
|
2019-04-16 18:09:30 +02:00
|
|
|
modules = [
|
|
|
|
"classify",
|
|
|
|
"exec",
|
|
|
|
"metadata",
|
2019-07-14 22:37:28 +02:00
|
|
|
"mtime",
|
2019-04-16 18:09:30 +02:00
|
|
|
"ugoira",
|
|
|
|
"zip",
|
|
|
|
]
|
|
|
|
|
2018-05-20 22:03:57 +02:00
|
|
|
log = logging.getLogger("postprocessor")
|
|
|
|
|
|
|
|
|
|
|
|
def find(name):
|
|
|
|
"""Return a postprocessor class with the given name"""
|
|
|
|
try:
|
|
|
|
return _cache[name]
|
|
|
|
except KeyError:
|
2019-07-15 16:33:03 +02:00
|
|
|
pass
|
|
|
|
|
|
|
|
klass = None
|
|
|
|
if name in modules: # prevent unwanted imports
|
2018-05-20 22:03:57 +02:00
|
|
|
try:
|
2019-07-15 16:33:03 +02:00
|
|
|
module = importlib.import_module("." + name, __package__)
|
|
|
|
except ImportError:
|
2018-09-04 22:49:57 +02:00
|
|
|
pass
|
2019-07-15 16:33:03 +02:00
|
|
|
else:
|
|
|
|
klass = module.__postprocessor__
|
|
|
|
_cache[name] = klass
|
|
|
|
return klass
|
2018-05-20 22:03:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
# --------------------------------------------------------------------
|
|
|
|
# internals
|
|
|
|
|
|
|
|
_cache = {}
|