Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / amd64 / html / python / dist / module-distutils.fancygetopt.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="dist.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="dist.html" title='Distributing Python Modules' />
8<link rel='index' href='genindex.html' title='Index' />
9<link rel='last' href='about.html' title='About this document...' />
10<link rel='help' href='about.html' title='About this document...' />
11<link rel="next" href="module-distutils.filelist.html" />
12<link rel="prev" href="module-distutils.errors.html" />
13<link rel="parent" href="api-reference.html" />
14<link rel="next" href="module-distutils.filelist.html" />
15<meta name='aesop' content='information' />
16<title>10.18 distutils.fancy_getopt -- Wrapper around the standard getopt module</title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="10.17 distutils.errors "
24 href="module-distutils.errors.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="10. API Reference"
27 href="api-reference.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="10.19 distutils.filelist "
30 href="module-distutils.filelist.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Distributing Python Modules</td>
33<td class='online-navigation'><img src='../icons/blank.png'
34 border='0' height='32' alt='' width='32' /></td>
35<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
36 border='0' height='32' alt='Module Index' width='32' /></a></td>
37<td class='online-navigation'><a rel="index" title="Index"
38 href="genindex.html"><img src='../icons/index.png'
39 border='0' height='32' alt='Index' width='32' /></A></td>
40</tr></table>
41<div class='online-navigation'>
42<b class="navlabel">Previous:</b>
43<a class="sectref" rel="prev" href="module-distutils.errors.html">10.17 distutils.errors </A>
44<b class="navlabel">Up:</b>
45<a class="sectref" rel="parent" href="api-reference.html">10. API Reference</A>
46<b class="navlabel">Next:</b>
47<a class="sectref" rel="next" href="module-distutils.filelist.html">10.19 distutils.filelist </A>
48</div>
49<hr /></div>
50</DIV>
51<!--End of Navigation Panel-->
52
53<H1><A NAME="SECTION00101800000000000000000">
5410.18 <tt class="module">distutils.fancy_getopt</tt>
55 -- Wrapper around the standard getopt module</A>
56</H1>
57<A NAME="module-distutils.fancygetopt"></A>
58
59<P>
60This module provides a wrapper around the standard <tt class="module">getopt</tt>
61module that provides the following additional features:
62
63<P>
64
65<UL>
66<LI>short and long options are tied together
67</LI>
68<LI>options have help strings, so <tt class="function">fancy_getopt</tt> could potentially
69create a complete usage summary
70</LI>
71<LI>options set attributes of a passed-in object
72</LI>
73<LI>boolean options can have ``negative aliases'' -- eg. if
74<b class="programopt">--quiet</b> is the ``negative alias'' of
75<b class="programopt">--verbose</b>, then <b class="programopt">--quiet</b> on the command
76line sets <var>verbose</var> to false.
77
78<P>
79</LI>
80</UL>
81
82<P>
83<b class="du-xxx">Should be replaced with <tt class="module">optik</tt> (which is also now
84known as <tt class="module">optparse</tt> in Python 2.3 and later).</b>
85
86<P>
87<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
88 <td><nobr><b><tt id='l2h-97' xml:id='l2h-97' class="function">fancy_getopt</tt></b>(</nobr></td>
89 <td><var>options, negative_opt, object, args</var>)</td></tr></table></dt>
90<dd>
91Wrapper function. <var>options</var> is a list of
92"<tt class="samp">(long_option, short_option, help_string)</tt>" 3-tuples as described in the
93constructor for <tt class="class">FancyGetopt</tt>. <var>negative_opt</var> should be a dictionary
94mapping option names to option names, both the key and value should be in the
95<var>options</var> list. <var>object</var> is an object which will be used to store
96values (see the <tt class="method">getopt()</tt> method of the <tt class="class">FancyGetopt</tt> class).
97<var>args</var> is the argument list. Will use <code>sys.argv[1:]</code> if you
98pass <code>None</code> as <var>args</var>.
99</dl>
100
101<P>
102<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
103 <td><nobr><b><tt id='l2h-98' xml:id='l2h-98' class="function">wrap_text</tt></b>(</nobr></td>
104 <td><var>text, width</var>)</td></tr></table></dt>
105<dd>
106Wraps <var>text</var> to less than <var>width</var> wide.
107
108<P>
109<span class="warning"><b class="label">Warning:</b>
110Should be replaced with <tt class="module">textwrap</tt> (which is available
111in Python 2.3 and later).</span>
112</dl>
113
114<P>
115<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
116 <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-99' xml:id='l2h-99' class="class">FancyGetopt</tt></b>(</nobr></td>
117 <td><var></var><big>[</big><var>option_table=<code>None</code></var><big>]</big><var></var>)</td></tr></table></dt>
118<dd>
119The option_table is a list of 3-tuples: "<tt class="samp">(long_option,
120short_option, help_string)</tt>"
121<P>
122If an option takes an argument, its <var>long_option</var> should have <code>'='</code>
123appended; <var>short_option</var> should just be a single character, no <code>':'</code>
124in any case. <var>short_option</var> should be <code>None</code> if a <var>long_option</var>
125doesn't have a corresponding <var>short_option</var>. All option tuples must have
126long options.
127</dl>
128
129<P>
130The <tt class="class">FancyGetopt</tt> class provides the following methods:
131
132<P>
133<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
134 <td><nobr><b><tt id='l2h-100' xml:id='l2h-100' class="method">getopt</tt></b>(</nobr></td>
135 <td><var></var><big>[</big><var>args=<code>None</code>, object=<code>None</code></var><big>]</big><var></var>)</td></tr></table></dt>
136<dd>
137Parse command-line options in args. Store as attributes on <var>object</var>.
138
139<P>
140If <var>args</var> is <code>None</code> or not supplied, uses <code>sys.argv[1:]</code>. If
141<var>object</var> is <code>None</code> or not supplied, creates a new <tt class="class">OptionDummy</tt>
142instance, stores option values there, and returns a tuple "<tt class="samp">(args,
143object)</tt>". If <var>object</var> is supplied, it is modified in place and
144<tt class="function">getopt()</tt> just returns <var>args</var>; in both cases, the returned
145<var>args</var> is a modified copy of the passed-in <var>args</var> list, which
146is left untouched.
147</dl>
148
149<P>
150<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
151 <td><nobr><b><tt id='l2h-101' xml:id='l2h-101' class="method">get_option_order</tt></b>(</nobr></td>
152 <td><var></var>)</td></tr></table></dt>
153<dd>
154Returns the list of "<tt class="samp">(option, value)</tt>" tuples processed by the
155previous run of <tt class="method">getopt()</tt> Raises <tt class="exception">RuntimeError</tt> if
156<tt class="method">getopt()</tt> hasn't been called yet.
157</dl>
158
159<P>
160<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
161 <td><nobr><b><tt id='l2h-102' xml:id='l2h-102' class="method">generate_help</tt></b>(</nobr></td>
162 <td><var></var><big>[</big><var>header=<code>None</code></var><big>]</big><var></var>)</td></tr></table></dt>
163<dd>
164Generate help text (a list of strings, one per suggested line of
165output) from the option table for this <tt class="class">FancyGetopt</tt> object.
166
167<P>
168If supplied, prints the supplied <var>header</var> at the top of the help.
169</dl>
170
171<P>
172
173<DIV CLASS="navigation">
174<div class='online-navigation'>
175<p></p><hr />
176<table align="center" width="100%" cellpadding="0" cellspacing="2">
177<tr>
178<td class='online-navigation'><a rel="prev" title="10.17 distutils.errors "
179 href="module-distutils.errors.html"><img src='../icons/previous.png'
180 border='0' height='32' alt='Previous Page' width='32' /></A></td>
181<td class='online-navigation'><a rel="parent" title="10. API Reference"
182 href="api-reference.html"><img src='../icons/up.png'
183 border='0' height='32' alt='Up One Level' width='32' /></A></td>
184<td class='online-navigation'><a rel="next" title="10.19 distutils.filelist "
185 href="module-distutils.filelist.html"><img src='../icons/next.png'
186 border='0' height='32' alt='Next Page' width='32' /></A></td>
187<td align="center" width="100%">Distributing Python Modules</td>
188<td class='online-navigation'><img src='../icons/blank.png'
189 border='0' height='32' alt='' width='32' /></td>
190<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
191 border='0' height='32' alt='Module Index' width='32' /></a></td>
192<td class='online-navigation'><a rel="index" title="Index"
193 href="genindex.html"><img src='../icons/index.png'
194 border='0' height='32' alt='Index' width='32' /></A></td>
195</tr></table>
196<div class='online-navigation'>
197<b class="navlabel">Previous:</b>
198<a class="sectref" rel="prev" href="module-distutils.errors.html">10.17 distutils.errors </A>
199<b class="navlabel">Up:</b>
200<a class="sectref" rel="parent" href="api-reference.html">10. API Reference</A>
201<b class="navlabel">Next:</b>
202<a class="sectref" rel="next" href="module-distutils.filelist.html">10.19 distutils.filelist </A>
203</div>
204</div>
205<hr />
206<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
207</DIV>
208<!--End of Navigation Panel-->
209<ADDRESS>
210See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
211</ADDRESS>
212</BODY>
213</HTML>