Commit 37d617cd authored by Jason R. Coombs's avatar Jason R. Coombs

Extract _resolve

parent 773f1ec3
...@@ -60,13 +60,17 @@ def find_module(module, paths=None): ...@@ -60,13 +60,17 @@ def find_module(module, paths=None):
def get_frozen_object(module, paths): def get_frozen_object(module, paths):
spec = importlib.util.find_spec(module, paths) spec = importlib.util.find_spec(module, paths)
if hasattr(spec, 'submodule_search_locations'): return spec.loader.get_code(_resolve(module))
spec = importlib.util.spec_from_loader('__init__.py', spec.loader)
return spec.loader.get_code(module)
def _resolve(spec):
return (
importlib.util.spec_from_loader('__init__.py', spec.loader)
if hasattr(spec, 'submodule_search_locations')
else spec
)
def get_module(module, paths, info): def get_module(module, paths, info):
spec = importlib.util.find_spec(module, paths) spec = importlib.util.find_spec(module, paths)
if hasattr(spec, 'submodule_search_locations'): return importlib.util.module_from_spec(_resolve(spec))
spec = importlib.util.spec_from_loader('__init__.py', spec.loader)
return importlib.util.module_from_spec(spec)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment