MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / get_source

Method get_source

tools/python-3.11.9-amd64/Lib/zipimport.py:232–254  ·  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

230
231
232 def get_source(self, fullname):
233 """get_source(fullname) -> source string.
234
235 Return the source code for the specified module. Raise ZipImportError
236 if the module couldn't be found, return None if the archive does
237 contain the module, but has no source for it.
238 """
239 mi = _get_module_info(self, fullname)
240 if mi is None:
241 raise ZipImportError(f"can't find module {fullname!r}", name=fullname)
242
243 path = _get_module_path(self, fullname)
244 if mi:
245 fullpath = _bootstrap_external._path_join(path, '__init__.py')
246 else:
247 fullpath = f'{path}.py'
248
249 try:
250 toc_entry = self._files[fullpath]
251 except KeyError:
252 # we have the module, but no source
253 return None
254 return _get_data(self.archive, toc_entry).decode()
255
256
257 # Return a bool signifying whether the module is a package or not.

Callers

nothing calls this directly

Calls 5

_get_module_infoFunction · 0.85
ZipImportErrorClass · 0.85
_get_module_pathFunction · 0.85
_get_dataFunction · 0.85
decodeMethod · 0.45

Tested by

no test coverage detected