Lines Matching +full:modules +full:- +full:2
1 """Find modules used by a script, using introspection."""
40 i = i+2
63 # sys.modules at runtime by calling ReplacePackage("_xmlplus", "xml")
79 # Python modules.
82 # resolved, ie. a starimport from a non-Python module.
100 self.modules = {}
126 self.indent = self.indent - 1
130 self.msg(2, "run_script", pathname)
142 def import_hook(self, name, caller=None, fromlist=None, level=-1):
153 def determine_parent(self, caller, level=-1):
156 self.msgout(4, "determine_parent -> None")
161 level -= 1
163 parent = self.modules[pname]
165 self.msgout(4, "determine_parent ->", parent)
169 pname = ".".join(pname.split(".")[:-level])
170 parent = self.modules[pname]
171 self.msgout(4, "determine_parent ->", parent)
174 parent = self.modules[pname]
176 self.msgout(4, "determine_parent ->", parent)
181 parent = self.modules[pname]
183 self.msgout(4, "determine_parent ->", parent)
185 self.msgout(4, "determine_parent -> None")
203 self.msgout(4, "find_head_package ->", (q, tail))
210 self.msgout(4, "find_head_package ->", (q, tail))
227 self.msgout(4, "load_tail ->", m)
247 modules = {}
249 # But we must also collect Python extension modules - although
258 self.msg(2, "can't list directory", dir)
264 if name[-n:] == suff:
265 mod = name[:-n]
268 modules[mod] = mod
269 return modules.keys()
274 m = self.modules[fqname]
278 self.msgout(3, "import_module ->", m)
281 self.msgout(3, "import_module -> None")
284 self.msgout(3, "import_module -> None")
290 self.msgout(3, "import_module ->", None)
298 self.msgout(3, "import_module ->", m)
303 self.msgin(2, "load_module", fqname, fp and "fp", pathname)
306 self.msgout(2, "load_module ->", m)
312 self.msgout(2, "raise ImportError: Bad magic number", pathname)
325 self.msgout(2, "load_module ->", m)
334 self.badmodules[name]["-"] = 1
336 def _safe_import_hook(self, name, caller, fromlist, level=-1):
344 self.msg(2, "ImportError:", str(msg))
355 self.msg(2, "ImportError:", str(msg))
373 and opargs[i-1][0] == LOAD_CONST):
374 fromlist = consts[opargs[i-1][1]]
389 if (op == IMPORT_NAME and i >= 2
390 and opargs[i-1][0] == opargs[i-2][0] == LOAD_CONST):
391 level = consts[opargs[i-2][1]]
392 fromlist = consts[opargs[i-1][1]]
393 if level == -1: # normal import
403 if sys.version_info >= (2, 5):
419 else: level = -1
430 mm = self.modules.get(m.__name__ + "." + name)
432 mm = self.modules.get(name)
456 self.msgin(2, "load_package", fqname, pathname)
469 self.msgout(2, "load_package ->", m)
475 if fqname in self.modules:
476 return self.modules[fqname]
477 self.modules[fqname] = m = Module(fqname)
487 self.msgout(3, "find_module -> Excluded", fullname)
498 """Print a report to stdout, listing the found modules with their
499 paths, as well as modules that are missing, or seem to be missing.
502 print " %-25s %s" % ("Name", "File")
503 print " %-25s %s" % ("----", "----")
504 # Print modules found
505 keys = self.modules.keys()
508 m = self.modules[key]
513 print "%-25s" % key, m.__file__ or ""
515 # Print missing modules
519 print "Missing modules:"
524 # Print modules that may be missing, but then again, maybe not...
535 """Return a list of modules that appear to be missing. Use
536 any_missing_maybe() if you want to know which modules are
543 """Return two lists, one with modules that are certainly missing
544 and one with modules that *may* be missing. The latter names could
562 pkg = self.modules.get(pkgname)
573 # from a non-Python module, so we simply can't be sure.
597 self.msgout(2, "co_filename %r changed to %r" \
600 self.msgout(2, "co_filename %r remains unchanged" \
631 if o == '-d':
633 if o == '-m':
635 if o == '-p':
637 if o == '-q':
639 if o == '-x':
660 if arg == '-m':
664 if arg[-2:] == '.*':
665 mf.import_hook(arg[:-2], None, ["*"])
672 return mf # for -i debugging