mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5743 from jdufresne/path-finder
Define _MockImporter as a MetaPathFinder
This commit is contained in:
commit
aebfd0df71
@ -98,7 +98,7 @@ class _MockModule(ModuleType):
|
|||||||
return o
|
return o
|
||||||
|
|
||||||
|
|
||||||
class _MockImporter:
|
class _MockImporter(MetaPathFinder):
|
||||||
def __init__(self, names):
|
def __init__(self, names):
|
||||||
# type: (List[str]) -> None
|
# type: (List[str]) -> None
|
||||||
self.names = names
|
self.names = names
|
||||||
@ -120,7 +120,7 @@ class _MockImporter:
|
|||||||
del sys.modules[m]
|
del sys.modules[m]
|
||||||
|
|
||||||
def find_module(self, name, path=None):
|
def find_module(self, name, path=None):
|
||||||
# type: (str, str) -> Any
|
# type: (str, Sequence[Union[bytes, str]]) -> Any
|
||||||
# check if name is (or is a descendant of) one of our base_packages
|
# check if name is (or is a descendant of) one of our base_packages
|
||||||
for n in self.names:
|
for n in self.names:
|
||||||
if n == name or name.startswith(n + '.'):
|
if n == name or name.startswith(n + '.'):
|
||||||
|
Loading…
Reference in New Issue
Block a user