Lines Matching +full:modules +full:- +full:2
1 """Find modules used by a script, using introspection."""
23 _PY_COMPILED = 2
45 # of another package into sys.modules at runtime by calling
57 # modules are being added/deleted/modified at runtime. In particular,
58 # test_modulefinder.py changes file tree contents in a cache-breaking way:
93 suffix = os.path.splitext(file_path)[-1]
107 # Python modules.
110 # resolved, ie. a starimport from a non-Python module.
128 self.modules = {}
154 self.indent = self.indent - 1
158 self.msg(2, "run_script", pathname)
170 def import_hook(self, name, caller=None, fromlist=None, level=-1):
181 def determine_parent(self, caller, level=-1):
184 self.msgout(4, "determine_parent -> None")
189 level -= 1
191 parent = self.modules[pname]
193 self.msgout(4, "determine_parent ->", parent)
197 pname = ".".join(pname.split(".")[:-level])
198 parent = self.modules[pname]
199 self.msgout(4, "determine_parent ->", parent)
202 parent = self.modules[pname]
204 self.msgout(4, "determine_parent ->", parent)
209 parent = self.modules[pname]
211 self.msgout(4, "determine_parent ->", parent)
213 self.msgout(4, "determine_parent -> None")
231 self.msgout(4, "find_head_package ->", (q, tail))
238 self.msgout(4, "find_head_package ->", (q, tail))
255 self.msgout(4, "load_tail ->", m)
275 modules = {}
277 # But we must also collect Python extension modules - although
287 self.msg(2, "can't list directory", dir)
293 if name[-n:] == suff:
294 mod = name[:-n]
297 modules[mod] = mod
298 return modules.keys()
303 m = self.modules[fqname]
307 self.msgout(3, "import_module ->", m)
310 self.msgout(3, "import_module -> None")
313 self.msgout(3, "import_module -> None")
319 self.msgout(3, "import_module ->", None)
329 self.msgout(3, "import_module ->", m)
334 self.msgin(2, "load_module", fqname, fp and "fp", pathname)
337 self.msgout(2, "load_module ->", m)
346 self.msgout(2, "raise ImportError: " + str(exc), pathname)
358 self.msgout(2, "load_module ->", m)
367 self.badmodules[name]["-"] = 1
369 def _safe_import_hook(self, name, caller, fromlist, level=-1):
377 self.msg(2, "ImportError:", str(msg))
380 self.msg(2, "SyntaxError:", str(msg))
392 self.msg(2, "ImportError:", str(msg))
406 if (op == IMPORT_NAME and i >= 2
407 and opargs[i-1][0] == opargs[i-2][0] == LOAD_CONST):
408 level = consts[opargs[i-2][1]]
409 fromlist = consts[opargs[i-1][1]]
440 mm = self.modules.get(m.__name__ + "." + name)
442 mm = self.modules.get(name)
466 self.msgin(2, "load_package", fqname, pathname)
480 self.msgout(2, "load_package ->", m)
487 if fqname in self.modules:
488 return self.modules[fqname]
489 self.modules[fqname] = m = Module(fqname)
499 self.msgout(3, "find_module -> Excluded", fullname)
511 """Print a report to stdout, listing the found modules with their
512 paths, as well as modules that are missing, or seem to be missing.
515 print(" %-25s %s" % ("Name", "File"))
516 print(" %-25s %s" % ("----", "----"))
517 # Print modules found
518 keys = sorted(self.modules.keys())
520 m = self.modules[key]
525 print("%-25s" % key, m.__file__ or "")
527 # Print missing modules
531 print("Missing modules:")
535 # Print modules that may be missing, but then again, maybe not...
545 """Return a list of modules that appear to be missing. Use
546 any_missing_maybe() if you want to know which modules are
553 """Return two lists, one with modules that are certainly missing
554 and one with modules that *may* be missing. The latter names could
572 pkg = self.modules.get(pkgname)
583 # from a non-Python module, so we simply can't be sure.
607 self.msgout(2, "co_filename %r changed to %r" \
610 self.msgout(2, "co_filename %r remains unchanged" \
637 if o == '-d':
639 if o == '-m':
641 if o == '-p':
643 if o == '-q':
645 if o == '-x':
666 if arg == '-m':
670 if arg[-2:] == '.*':
671 mf.import_hook(arg[:-2], None, ["*"])
678 return mf # for -i debugging