Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / tools / src / nas,5.n2.os.2 / lib / python / html / python / lib / module-modulefinder.html
CommitLineData
86530b38
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="next" href="module-code.html" />
13<link rel="prev" href="module-pkgutil.html" />
14<link rel="parent" href="python.html" />
15<link rel="next" href="module-code.html" />
16<meta name='aesop' content='information' />
17<title>3.24 modulefinder -- Find modules used by a script</title>
18</head>
19<body>
20<DIV CLASS="navigation">
21<div id='top-navigation-panel' xml:id='top-navigation-panel'>
22<table align="center" width="100%" cellpadding="0" cellspacing="2">
23<tr>
24<td class='online-navigation'><a rel="prev" title="3.23 pkgutil "
25 href="module-pkgutil.html"><img src='../icons/previous.png'
26 border='0' height='32' alt='Previous Page' width='32' /></A></td>
27<td class='online-navigation'><a rel="parent" title="3. Python Runtime Services"
28 href="python.html"><img src='../icons/up.png'
29 border='0' height='32' alt='Up One Level' width='32' /></A></td>
30<td class='online-navigation'><a rel="next" title="3.25 code "
31 href="module-code.html"><img src='../icons/next.png'
32 border='0' height='32' alt='Next Page' width='32' /></A></td>
33<td align="center" width="100%">Python Library Reference</td>
34<td class='online-navigation'><a rel="contents" title="Table of Contents"
35 href="contents.html"><img src='../icons/contents.png'
36 border='0' height='32' alt='Contents' width='32' /></A></td>
37<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
38 border='0' height='32' alt='Module Index' width='32' /></a></td>
39<td class='online-navigation'><a rel="index" title="Index"
40 href="genindex.html"><img src='../icons/index.png'
41 border='0' height='32' alt='Index' width='32' /></A></td>
42</tr></table>
43<div class='online-navigation'>
44<b class="navlabel">Previous:</b>
45<a class="sectref" rel="prev" href="module-pkgutil.html">3.23 pkgutil </A>
46<b class="navlabel">Up:</b>
47<a class="sectref" rel="parent" href="python.html">3. Python Runtime Services</A>
48<b class="navlabel">Next:</b>
49<a class="sectref" rel="next" href="module-code.html">3.25 code </A>
50</div>
51<hr /></div>
52</DIV>
53<!--End of Navigation Panel-->
54
55<H1><A NAME="SECTION0052400000000000000000">
563.24 <tt class="module">modulefinder</tt> --
57 Find modules used by a script</A>
58</H1>
59
60<P>
61<A NAME="module-modulefinder"></A>
62
63<P>
64This module provides a <tt class="class">ModuleFinder</tt> class that can be used to
65determine the set of modules imported by a script.
66<code>modulefinder.py</code> can also be run as a script, giving the
67filename of a Python script as its argument, after which a report of
68the imported modules will be printed.
69
70<P>
71<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
72 <td><nobr><b><tt id='l2h-738' xml:id='l2h-738' class="function">AddPackagePath</tt></b>(</nobr></td>
73 <td><var>pkg_name, path</var>)</td></tr></table></dt>
74<dd>
75Record that the package named <var>pkg_name</var> can be found in the specified <var>path</var>.
76</dl>
77
78<P>
79<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
80 <td><nobr><b><tt id='l2h-739' xml:id='l2h-739' class="function">ReplacePackage</tt></b>(</nobr></td>
81 <td><var>oldname, newname</var>)</td></tr></table></dt>
82<dd>
83Allows specifying that the module named <var>oldname</var> is in fact
84the package named <var>newname</var>. The most common usage would be
85to handle how the <tt class="module">_xmlplus</tt> package replaces the <tt class="module">xml</tt>
86package.
87</dl>
88
89<P>
90<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
91 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-740' xml:id='l2h-740' class="class">ModuleFinder</tt></b>(</nobr></td>
92 <td><var></var><big>[</big><var>path=None, debug=0, excludes=[], replace_paths=[]</var><big>]</big><var></var>)</td></tr></table></dt>
93<dd>
94
95<P>
96This class provides <tt class="method">run_script()</tt> and <tt class="method">report()</tt>
97methods to determine the set of modules imported by a script.
98<var>path</var> can be a list of directories to search for modules; if not
99specified, <code>sys.path</code> is used.
100<var>debug</var> sets the debugging level; higher values make the class print
101debugging messages about what it's doing.
102<var>excludes</var> is a list of module names to exclude from the analysis.
103<var>replace_paths</var> is a list of <code>(<var>oldpath</var>, <var>newpath</var>)</code>
104tuples that will be replaced in module paths.
105</dl>
106
107<P>
108<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
109 <td><nobr><b><tt id='l2h-741' xml:id='l2h-741' class="method">report</tt></b>(</nobr></td>
110 <td><var></var>)</td></tr></table></dt>
111<dd>
112Print a report to standard output that lists the modules imported by the script
113and their
114paths, as well as modules that are missing or seem to be missing.
115</dl>
116
117<P>
118<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
119 <td><nobr><b><tt id='l2h-742' xml:id='l2h-742' class="method">run_script</tt></b>(</nobr></td>
120 <td><var>pathname</var>)</td></tr></table></dt>
121<dd>
122Analyze the contents of the <var>pathname</var> file, which must contain
123Python code.
124</dl>
125
126<P>
127
128<DIV CLASS="navigation">
129<div class='online-navigation'>
130<p></p><hr />
131<table align="center" width="100%" cellpadding="0" cellspacing="2">
132<tr>
133<td class='online-navigation'><a rel="prev" title="3.23 pkgutil "
134 href="module-pkgutil.html"><img src='../icons/previous.png'
135 border='0' height='32' alt='Previous Page' width='32' /></A></td>
136<td class='online-navigation'><a rel="parent" title="3. Python Runtime Services"
137 href="python.html"><img src='../icons/up.png'
138 border='0' height='32' alt='Up One Level' width='32' /></A></td>
139<td class='online-navigation'><a rel="next" title="3.25 code "
140 href="module-code.html"><img src='../icons/next.png'
141 border='0' height='32' alt='Next Page' width='32' /></A></td>
142<td align="center" width="100%">Python Library Reference</td>
143<td class='online-navigation'><a rel="contents" title="Table of Contents"
144 href="contents.html"><img src='../icons/contents.png'
145 border='0' height='32' alt='Contents' width='32' /></A></td>
146<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
147 border='0' height='32' alt='Module Index' width='32' /></a></td>
148<td class='online-navigation'><a rel="index" title="Index"
149 href="genindex.html"><img src='../icons/index.png'
150 border='0' height='32' alt='Index' width='32' /></A></td>
151</tr></table>
152<div class='online-navigation'>
153<b class="navlabel">Previous:</b>
154<a class="sectref" rel="prev" href="module-pkgutil.html">3.23 pkgutil </A>
155<b class="navlabel">Up:</b>
156<a class="sectref" rel="parent" href="python.html">3. Python Runtime Services</A>
157<b class="navlabel">Next:</b>
158<a class="sectref" rel="next" href="module-code.html">3.25 code </A>
159</div>
160</div>
161<hr />
162<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
163</DIV>
164<!--End of Navigation Panel-->
165<ADDRESS>
166See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
167</ADDRESS>
168</BODY>
169</HTML>