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:
parent
0151e250f5
commit
c41ff9441e
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user