rest25/library/modulefinder.rst => rest262/library/modulefinder.rst
35   the set of modules imported by a script. *path* can be a list of directories to
36   search for modules; if not specified, ``sys.path`` is used.  *debug* sets the
37   debugging level; higher values make the class print  debugging messages about
38   what it's doing. *excludes* is a list of module names to exclude from the
39   analysis. *replace_paths* is a list of ``(oldpath, newpath)`` tuples that will
40   be replaced in module paths.
41
42
n43-.. method:: ModuleFinder.report()
n43+   .. method:: report()
44
n45-   Print a report to standard output that lists the modules imported by the script
n45+      Print a report to standard output that lists the modules imported by the
46-   and their paths, as well as modules that are missing or seem to be missing.
46+      script and their paths, as well as modules that are missing or seem to be
47+      missing.
48+ 
49+   .. method:: run_script(pathname)
50+ 
51+      Analyze the contents of the *pathname* file, which must contain Python
52+      code.
53+ 
54+   .. attribute:: modules
55+ 
56+      A dictionary mapping module names to modules. See
57+      :ref:`modulefinder-example`
47
48
n49-.. method:: ModuleFinder.run_script(pathname)
n60+.. _modulefinder-example:
50
n51-   Analyze the contents of the *pathname* file, which must contain  Python code.
n62+Example usage of :class:`ModuleFinder`
63+--------------------------------------
52
t65+The script that is going to get analyzed later on (bacon.py)::
66+ 
67+   import re, itertools
68+ 
69+   try:
70+       import baconhameggs
71+   except ImportError:
72+       pass
73+ 
74+   try:
75+       import guido.python.ham
76+   except ImportError:
77+       pass
78+ 
79+ 
80+The script that will output the report of bacon.py::
81+ 
82+   from modulefinder import ModuleFinder
83+ 
84+   finder = ModuleFinder()
85+   finder.run_script('bacon.py')
86+ 
87+   print 'Loaded modules:'
88+   for name, mod in finder.modules.iteritems():
89+       print '%s: ' % name,
90+       print ','.join(mod.globalnames.keys()[:3])
91+ 
92+   print '-'*50
93+   print 'Modules not imported:'
94+   print '\n'.join(finder.badmodules.iterkeys())
95+ 
96+Sample output (may vary depending on the architecture)::
97+ 
98+    Loaded modules:
99+    _types:
100+    copy_reg:  _inverted_registry,_slotnames,__all__
101+    sre_compile:  isstring,_sre,_optimize_unicode
102+    _sre:
103+    sre_constants:  REPEAT_ONE,makedict,AT_END_LINE
104+    sys:
105+    re:  __module__,finditer,_expand
106+    itertools:
107+    __main__:  re,itertools,baconhameggs
108+    sre_parse:  __getslice__,_PATTERNENDERS,SRE_FLAG_UNICODE
109+    array:
110+    types:  __module__,IntType,TypeType
111+    ---------------------------------------------------
112+    Modules not imported:
113+    guido.python.ham
114+    baconhameggs
115+ 
116+ 
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op