mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
* GH-119668: expose importlib.NamespacePath Signed-off-by: Filipe Laíns <lains@riseup.net> * add news Signed-off-by: Filipe Laíns <lains@riseup.net> * add to docs Signed-off-by: Filipe Laíns <lains@riseup.net> * Apply suggestions from code review Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> * Fix news (importlib.NamespacePath > importlib.machinery.NamespacePath) Signed-off-by: Filipe Laíns <lains@riseup.net> * Link to module.__path__ in NamespacePath docs Signed-off-by: Filipe Laíns <lains@riseup.net> * Mention the path argument in the documentation Signed-off-by: Filipe Laíns <lains@riseup.net> * Simplify docs text Signed-off-by: Filipe Laíns <lains@riseup.net> * Highlight argument names in docs text Signed-off-by: Filipe Laíns <lains@riseup.net> * Update Lib/importlib/_bootstrap_external.py Co-authored-by: Brett Cannon <brett@python.org> * Rewrite NamespacePath's doc Signed-off-by: Filipe Laíns <lains@riseup.net> * Specify path_finder's type in the NamespacePath docstring Signed-off-by: Filipe Laíns <lains@riseup.net> * Fix doc tests Signed-off-by: Filipe Laíns <lains@riseup.net> * Apply suggestions from code review Co-authored-by: Barry Warsaw <barry@python.org> * Fix doc lint Signed-off-by: Filipe Laíns <lains@riseup.net> * Update Doc/library/importlib.rst Co-authored-by: Brett Cannon <brett@python.org> --------- Signed-off-by: Filipe Laíns <lains@riseup.net> Co-authored-by: Brett Cannon <brett@python.org> Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> Co-authored-by: Barry Warsaw <barry@python.org>
51 lines
2.2 KiB
Python
51 lines
2.2 KiB
Python
"""The machinery of importlib: finders, loaders, hooks, etc."""
|
|
|
|
from ._bootstrap import ModuleSpec
|
|
from ._bootstrap import BuiltinImporter
|
|
from ._bootstrap import FrozenImporter
|
|
from ._bootstrap_external import (
|
|
SOURCE_SUFFIXES, BYTECODE_SUFFIXES, EXTENSION_SUFFIXES,
|
|
DEBUG_BYTECODE_SUFFIXES as _DEBUG_BYTECODE_SUFFIXES,
|
|
OPTIMIZED_BYTECODE_SUFFIXES as _OPTIMIZED_BYTECODE_SUFFIXES
|
|
)
|
|
from ._bootstrap_external import WindowsRegistryFinder
|
|
from ._bootstrap_external import PathFinder
|
|
from ._bootstrap_external import FileFinder
|
|
from ._bootstrap_external import SourceFileLoader
|
|
from ._bootstrap_external import SourcelessFileLoader
|
|
from ._bootstrap_external import ExtensionFileLoader
|
|
from ._bootstrap_external import AppleFrameworkLoader
|
|
from ._bootstrap_external import NamespaceLoader
|
|
from ._bootstrap_external import NamespacePath
|
|
|
|
|
|
def all_suffixes():
|
|
"""Returns a list of all recognized module suffixes for this process"""
|
|
return SOURCE_SUFFIXES + BYTECODE_SUFFIXES + EXTENSION_SUFFIXES
|
|
|
|
|
|
__all__ = ['AppleFrameworkLoader', 'BYTECODE_SUFFIXES', 'BuiltinImporter',
|
|
'DEBUG_BYTECODE_SUFFIXES', 'EXTENSION_SUFFIXES',
|
|
'ExtensionFileLoader', 'FileFinder', 'FrozenImporter', 'ModuleSpec',
|
|
'NamespaceLoader', 'OPTIMIZED_BYTECODE_SUFFIXES', 'PathFinder',
|
|
'SOURCE_SUFFIXES', 'SourceFileLoader', 'SourcelessFileLoader',
|
|
'WindowsRegistryFinder', 'all_suffixes']
|
|
|
|
|
|
def __getattr__(name):
|
|
import warnings
|
|
|
|
if name == 'DEBUG_BYTECODE_SUFFIXES':
|
|
warnings.warn('importlib.machinery.DEBUG_BYTECODE_SUFFIXES is '
|
|
'deprecated; use importlib.machinery.BYTECODE_SUFFIXES '
|
|
'instead.',
|
|
DeprecationWarning, stacklevel=2)
|
|
return _DEBUG_BYTECODE_SUFFIXES
|
|
elif name == 'OPTIMIZED_BYTECODE_SUFFIXES':
|
|
warnings.warn('importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES is '
|
|
'deprecated; use importlib.machinery.BYTECODE_SUFFIXES '
|
|
'instead.',
|
|
DeprecationWarning, stacklevel=2)
|
|
return _OPTIMIZED_BYTECODE_SUFFIXES
|
|
|
|
raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
|