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

Method get_source

Lib/zipimport.py:175–197  ·  view source on GitHub ↗

get_source(fullname) -> source string. Return the source code for the specified module. Raise ZipImportError if the module couldn't be found, return None if the archive does contain the module, but has no source for it.

(self, fullname)

Source from the content-addressed store, hash-verified

173
174
175 def get_source(self, fullname):
176 """get_source(fullname) -> source string.
177
178 Return the source code for the specified module. Raise ZipImportError
179 if the module couldn't be found, return None if the archive does
180 contain the module, but has no source for it.
181 """
182 mi = _get_module_info(self, fullname)
183 if mi is None:
184 raise ZipImportError(f"can't find module {fullname!r}", name=fullname)
185
186 path = _get_module_path(self, fullname)
187 if mi:
188 fullpath = _bootstrap_external._path_join(path, '__init__.py')
189 else:
190 fullpath = f'{path}.py'
191
192 try:
193 toc_entry = self._get_files()[fullpath]
194 except KeyError:
195 # we have the module, but no source
196 return None
197 return _get_data(self.archive, toc_entry).decode()
198
199
200 # Return a bool signifying whether the module is a package or not.

Callers 2

runMethod · 0.45
_readmoduleFunction · 0.45

Calls 6

_get_filesMethod · 0.95
ZipImportErrorClass · 0.85
_get_module_pathFunction · 0.85
_get_dataFunction · 0.85
_get_module_infoFunction · 0.70
decodeMethod · 0.45

Tested by

no test coverage detected