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

Method import_module

Lib/modulefinder.py:297–327  ·  view source on GitHub ↗
(self, partname, fqname, parent)

Source from the content-addressed store, hash-verified

295 return modules.keys()
296
297 def import_module(self, partname, fqname, parent):
298 self.msgin(3, "import_module", partname, fqname, parent)
299 try:
300 m = self.modules[fqname]
301 except KeyError:
302 pass
303 else:
304 self.msgout(3, "import_module ->", m)
305 return m
306 if fqname in self.badmodules:
307 self.msgout(3, "import_module -> None")
308 return None
309 if parent and parent.__path__ is None:
310 self.msgout(3, "import_module -> None")
311 return None
312 try:
313 fp, pathname, stuff = self.find_module(partname,
314 parent and parent.__path__, parent)
315 except ImportError:
316 self.msgout(3, "import_module ->", None)
317 return None
318
319 try:
320 m = self.load_module(fqname, fp, pathname, stuff)
321 finally:
322 if fp:
323 fp.close()
324 if parent:
325 setattr(parent, partname, m)
326 self.msgout(3, "import_module ->", m)
327 return m
328
329 def load_module(self, fqname, fp, pathname, file_info):
330 suffix, mode, type = file_info

Callers 7

find_head_packageMethod · 0.95
load_tailMethod · 0.95
ensure_fromlistMethod · 0.95
iter_importersFunction · 0.45
resolve_nameFunction · 0.45
_mainFunction · 0.45
safeimportFunction · 0.45

Calls 6

msginMethod · 0.95
msgoutMethod · 0.95
find_moduleMethod · 0.95
load_moduleMethod · 0.95
setattrFunction · 0.85
closeMethod · 0.45

Tested by

no test coverage detected