From 6547ff433596bfde2e6510b630e523c5eb59d9a9 Mon Sep 17 00:00:00 2001 From: coletdjnz Date: Sat, 19 Oct 2024 16:55:23 +1300 Subject: [PATCH] minor refactoring --- yt_dlp/plugins.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/yt_dlp/plugins.py b/yt_dlp/plugins.py index 0fb3962270..97ef41fa59 100644 --- a/yt_dlp/plugins.py +++ b/yt_dlp/plugins.py @@ -162,7 +162,7 @@ def iter_modules(subpackage): yield from pkgutil.iter_modules(path=pkg.__path__, prefix=f'{fullname}.') -def get_regular_modules(module, module_name, suffix): +def get_regular_classes(module, module_name, suffix): # Find standard public plugin classes (not overrides) return inspect.getmembers(module, lambda obj: ( inspect.isclass(obj) @@ -174,10 +174,7 @@ def get_regular_modules(module, module_name, suffix): )) -load_module = get_regular_modules - - -def get_override_modules(module, module_name, suffix): +def get_override_classes(module, module_name, suffix): # Find override plugin classes def predicate(obj): if not inspect.isclass(obj): @@ -250,8 +247,8 @@ def load_plugins(plugin_type: PluginType): f'Error while importing module {module_name!r}\n{traceback.format_exc(limit=-1)}', ) continue - regular_classes.update(get_regular_modules(module, module_name, suffix)) - override_classes.update(get_override_modules(module, module_name, suffix)) + regular_classes.update(get_regular_classes(module, module_name, suffix)) + override_classes.update(get_override_classes(module, module_name, suffix)) # Compat: old plugin system using __init__.py # Note: plugins imported this way do not show up in directories() @@ -265,7 +262,7 @@ def load_plugins(plugin_type: PluginType): plugins = importlib.util.module_from_spec(spec) sys.modules[spec.name] = plugins spec.loader.exec_module(plugins) - regular_classes.update(get_regular_modules(plugins, spec.name, suffix)) + regular_classes.update(get_regular_classes(plugins, spec.name, suffix)) # Configure override classes for _, klass in override_classes.items():