mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-01-19 10:26:56 +01:00
Make globals internal-only
This commit is contained in:
parent
4266658602
commit
413ae7693b
9 changed files with 14 additions and 13 deletions
|
@ -11,7 +11,7 @@ sys.path.append(str(TEST_DATA_DIR))
|
||||||
importlib.invalidate_caches()
|
importlib.invalidate_caches()
|
||||||
|
|
||||||
from yt_dlp.plugins import PACKAGE_NAME, PluginType, directories, load_plugins
|
from yt_dlp.plugins import PACKAGE_NAME, PluginType, directories, load_plugins
|
||||||
from yt_dlp.globals import extractors, postprocessors
|
from yt_dlp._globals import extractors, postprocessors
|
||||||
|
|
||||||
|
|
||||||
class TestPlugins(unittest.TestCase):
|
class TestPlugins(unittest.TestCase):
|
||||||
|
|
|
@ -33,7 +33,7 @@ from .downloader.rtmp import rtmpdump_version
|
||||||
from .extractor import gen_extractor_classes, get_info_extractor, import_extractors
|
from .extractor import gen_extractor_classes, get_info_extractor, import_extractors
|
||||||
from .extractor.common import UnsupportedURLIE
|
from .extractor.common import UnsupportedURLIE
|
||||||
from .extractor.openload import PhantomJSwrapper
|
from .extractor.openload import PhantomJSwrapper
|
||||||
from .globals import (
|
from ._globals import (
|
||||||
IN_CLI,
|
IN_CLI,
|
||||||
LAZY_EXTRACTORS,
|
LAZY_EXTRACTORS,
|
||||||
plugin_ies,
|
plugin_ies,
|
||||||
|
|
|
@ -20,7 +20,7 @@ from .downloader.external import get_external_downloader
|
||||||
from .extractor import list_extractor_classes
|
from .extractor import list_extractor_classes
|
||||||
from .extractor.adobepass import MSO_INFO
|
from .extractor.adobepass import MSO_INFO
|
||||||
from .networking.impersonate import ImpersonateTarget
|
from .networking.impersonate import ImpersonateTarget
|
||||||
from .globals import IN_CLI, plugin_dirs
|
from ._globals import IN_CLI, plugin_dirs
|
||||||
from .options import parseOpts
|
from .options import parseOpts
|
||||||
from .plugins import load_all_plugin_types
|
from .plugins import load_all_plugin_types
|
||||||
from .postprocessor import (
|
from .postprocessor import (
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from contextvars import ContextVar
|
from contextvars import ContextVar
|
||||||
|
|
||||||
# NAME = 'yt-dlp'
|
# Internal only - no backwards compatibility guaranteed
|
||||||
|
|
||||||
postprocessors = ContextVar('postprocessors', default={})
|
postprocessors = ContextVar('postprocessors', default={})
|
||||||
extractors = ContextVar('extractors', default={})
|
extractors = ContextVar('extractors', default={})
|
|
@ -1,5 +1,5 @@
|
||||||
|
from .._globals import extractors as _extractors_context
|
||||||
from ..compat.compat_utils import passthrough_module
|
from ..compat.compat_utils import passthrough_module
|
||||||
from ..globals import extractors as _extractors_context
|
|
||||||
|
|
||||||
passthrough_module(__name__, '.extractors')
|
passthrough_module(__name__, '.extractors')
|
||||||
del passthrough_module
|
del passthrough_module
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from ..globals import LAZY_EXTRACTORS
|
from .._globals import LAZY_EXTRACTORS
|
||||||
from ..globals import extractors as _extractors_context
|
from .._globals import extractors as _extractors_context
|
||||||
|
|
||||||
_CLASS_LOOKUP = None
|
_CLASS_LOOKUP = None
|
||||||
if not os.environ.get('YTDLP_NO_LAZY_EXTRACTORS'):
|
if not os.environ.get('YTDLP_NO_LAZY_EXTRACTORS'):
|
||||||
|
|
|
@ -17,7 +17,7 @@ from contextvars import ContextVar
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from zipfile import ZipFile
|
from zipfile import ZipFile
|
||||||
|
|
||||||
from .globals import (
|
from ._globals import (
|
||||||
extractors,
|
extractors,
|
||||||
plugin_dirs,
|
plugin_dirs,
|
||||||
plugin_ies,
|
plugin_ies,
|
||||||
|
@ -268,7 +268,7 @@ def load_plugins(plugin_type: PluginType):
|
||||||
regular_classes.update(get_regular_modules(plugins, spec.name, suffix))
|
regular_classes.update(get_regular_modules(plugins, spec.name, suffix))
|
||||||
|
|
||||||
# Configure override classes
|
# Configure override classes
|
||||||
for name, klass in override_classes.items():
|
for _, klass in override_classes.items():
|
||||||
plugin_name = getattr(klass, '_plugin_name', None)
|
plugin_name = getattr(klass, '_plugin_name', None)
|
||||||
if not plugin_name:
|
if not plugin_name:
|
||||||
# these should always have plugin_name
|
# these should always have plugin_name
|
||||||
|
@ -298,6 +298,7 @@ def load_all_plugin_types():
|
||||||
for plugin_type in PluginType:
|
for plugin_type in PluginType:
|
||||||
load_plugins(plugin_type)
|
load_plugins(plugin_type)
|
||||||
|
|
||||||
|
|
||||||
sys.meta_path.insert(0, PluginFinder(f'{PACKAGE_NAME}.extractor', f'{PACKAGE_NAME}.postprocessor'))
|
sys.meta_path.insert(0, PluginFinder(f'{PACKAGE_NAME}.extractor', f'{PACKAGE_NAME}.postprocessor'))
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|
|
@ -33,7 +33,7 @@ from .movefilesafterdownload import MoveFilesAfterDownloadPP
|
||||||
from .sponskrub import SponSkrubPP
|
from .sponskrub import SponSkrubPP
|
||||||
from .sponsorblock import SponsorBlockPP
|
from .sponsorblock import SponsorBlockPP
|
||||||
from .xattrpp import XAttrMetadataPP
|
from .xattrpp import XAttrMetadataPP
|
||||||
from ..globals import plugin_pps, postprocessors
|
from .._globals import plugin_pps, postprocessors
|
||||||
from ..plugins import PACKAGE_NAME
|
from ..plugins import PACKAGE_NAME
|
||||||
from ..utils import deprecation_warning
|
from ..utils import deprecation_warning
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ from ..compat import (
|
||||||
compat_os_name,
|
compat_os_name,
|
||||||
)
|
)
|
||||||
from ..dependencies import xattr
|
from ..dependencies import xattr
|
||||||
from ..globals import IN_CLI
|
from .._globals import IN_CLI
|
||||||
|
|
||||||
__name__ = __name__.rsplit('.', 1)[0] # noqa: A001: Pretend to be the parent module
|
__name__ = __name__.rsplit('.', 1)[0] # noqa: A001: Pretend to be the parent module
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue