1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

improve find() for downloaders and postprocessors

This commit is contained in:
Mike Fährmann 2019-07-15 16:33:03 +02:00
parent 0151e250f5
commit c41ff9441e
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 12 additions and 8 deletions

View File

@ -30,9 +30,10 @@ def find(scheme):
if scheme in modules: # prevent unwanted imports
try:
module = importlib.import_module("." + scheme, __package__)
klass = module.__downloader__
except ImportError:
pass
else:
klass = module.__downloader__
if scheme == "http":
_cache["http"] = _cache["https"] = klass

View File

@ -28,15 +28,18 @@ def find(name):
try:
return _cache[name]
except KeyError:
klass = None
pass
klass = None
if name in modules: # prevent unwanted imports
try:
if name in modules: # prevent unwanted imports
module = importlib.import_module("." + name, __package__)
klass = module.__postprocessor__
except (ImportError, AttributeError, TypeError):
module = importlib.import_module("." + name, __package__)
except ImportError:
pass
_cache[name] = klass
return klass
else:
klass = module.__postprocessor__
_cache[name] = klass
return klass
# --------------------------------------------------------------------