MCPcopy Index your code
hub / github.com/RustPython/RustPython / find_spec

Method find_spec

Lib/zipimport.py:103–128  ·  view source on GitHub ↗

Create a ModuleSpec for the specified module. Returns None if the module cannot be found.

(self, fullname, target=None)

Source from the content-addressed store, hash-verified

101
102
103 def find_spec(self, fullname, target=None):
104 """Create a ModuleSpec for the specified module.
105
106 Returns None if the module cannot be found.
107 """
108 module_info = _get_module_info(self, fullname)
109 if module_info is not None:
110 return _bootstrap.spec_from_loader(fullname, self, is_package=module_info)
111 else:
112 # Not a module or regular package. See if this is a directory, and
113 # therefore possibly a portion of a namespace package.
114
115 # We're only interested in the last path component of fullname
116 # earlier components are recorded in self.prefix.
117 modpath = _get_module_path(self, fullname)
118 if _is_dir(self, modpath):
119 # This is possibly a portion of a namespace
120 # package. Return the string representing its path,
121 # without a trailing separator.
122 path = f'{self.archive}{path_sep}{modpath}'
123 spec = _bootstrap.ModuleSpec(name=fullname, loader=None,
124 is_package=True)
125 spec.submodule_search_locations.append(path)
126 return spec
127 else:
128 return None
129
130 def get_code(self, fullname):
131 """get_code(fullname) -> code object.

Callers 5

extend_pathFunction · 0.45
get_dataFunction · 0.45
_find_moduleFunction · 0.45
runMethod · 0.45
_get_module_detailsFunction · 0.45

Calls 4

_get_module_pathFunction · 0.85
_is_dirFunction · 0.85
_get_module_infoFunction · 0.70
appendMethod · 0.45

Tested by

no test coverage detected