1
2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
3<html><head><title>Python: module telemetry.internal.util.command_line</title>
4<meta charset="utf-8">
5</head><body bgcolor="#f0f0f8">
6
7<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
8<tr bgcolor="#7799ee">
9<td valign=bottom>&nbsp;<br>
10<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong><a href="telemetry.html"><font color="#ffffff">telemetry</font></a>.<a href="telemetry.internal.html"><font color="#ffffff">internal</font></a>.<a href="telemetry.internal.util.html"><font color="#ffffff">util</font></a>.command_line</strong></big></big></font></td
11><td align=right valign=bottom
12><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="../telemetry/internal/util/command_line.py">telemetry/internal/util/command_line.py</a></font></td></tr></table>
13    <p><tt>#&nbsp;Copyright&nbsp;2014&nbsp;The&nbsp;Chromium&nbsp;Authors.&nbsp;All&nbsp;rights&nbsp;reserved.<br>
14#&nbsp;Use&nbsp;of&nbsp;this&nbsp;source&nbsp;code&nbsp;is&nbsp;governed&nbsp;by&nbsp;a&nbsp;BSD-style&nbsp;license&nbsp;that&nbsp;can&nbsp;be<br>
15#&nbsp;found&nbsp;in&nbsp;the&nbsp;LICENSE&nbsp;file.</tt></p>
16<p>
17<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
18<tr bgcolor="#aa55cc">
19<td colspan=3 valign=bottom>&nbsp;<br>
20<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
21
22<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
23<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="argparse.html">argparse</a><br>
24</td><td width="25%" valign=top><a href="telemetry.internal.util.camel_case.html">telemetry.internal.util.camel_case</a><br>
25</td><td width="25%" valign=top><a href="difflib.html">difflib</a><br>
26</td><td width="25%" valign=top><a href="optparse.html">optparse</a><br>
27</td></tr></table></td></tr></table><p>
28<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
29<tr bgcolor="#ee77aa">
30<td colspan=3 valign=bottom>&nbsp;<br>
31<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
32
33<tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
34<td width="100%"><dl>
35<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a>
36</font></dt><dd>
37<dl>
38<dt><font face="helvetica, arial"><a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">ArgumentHandlerMixIn</a>
39</font></dt><dd>
40<dl>
41<dt><font face="helvetica, arial"><a href="telemetry.internal.util.command_line.html#Command">Command</a>
42</font></dt><dd>
43<dl>
44<dt><font face="helvetica, arial"><a href="telemetry.internal.util.command_line.html#OptparseCommand">OptparseCommand</a>
45</font></dt><dt><font face="helvetica, arial"><a href="telemetry.internal.util.command_line.html#SubcommandCommand">SubcommandCommand</a>
46</font></dt></dl>
47</dd>
48</dl>
49</dd>
50</dl>
51</dd>
52</dl>
53 <p>
54<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
55<tr bgcolor="#ffc8d8">
56<td colspan=3 valign=bottom>&nbsp;<br>
57<font color="#000000" face="helvetica, arial"><a name="ArgumentHandlerMixIn">class <strong>ArgumentHandlerMixIn</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr>
58
59<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
60<td colspan=2><tt>A&nbsp;structured&nbsp;way&nbsp;to&nbsp;handle&nbsp;command-line&nbsp;arguments.<br>
61&nbsp;<br>
62In&nbsp;AddCommandLineArgs,&nbsp;add&nbsp;command-line&nbsp;arguments.<br>
63In&nbsp;ProcessCommandLineArgs,&nbsp;validate&nbsp;them&nbsp;and&nbsp;store&nbsp;them&nbsp;in&nbsp;a&nbsp;private&nbsp;class<br>
64variable.&nbsp;This&nbsp;way,&nbsp;each&nbsp;class&nbsp;encapsulates&nbsp;its&nbsp;own&nbsp;arguments,&nbsp;without&nbsp;needing<br>
65to&nbsp;pass&nbsp;an&nbsp;arguments&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;around&nbsp;everywhere.<br>&nbsp;</tt></td></tr>
66<tr><td>&nbsp;</td>
67<td width="100%">Class methods defined here:<br>
68<dl><dt><a name="ArgumentHandlerMixIn-AddCommandLineArgs"><strong>AddCommandLineArgs</strong></a>(cls, parser)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Override&nbsp;to&nbsp;accept&nbsp;custom&nbsp;command-line&nbsp;arguments.</tt></dd></dl>
69
70<dl><dt><a name="ArgumentHandlerMixIn-ProcessCommandLineArgs"><strong>ProcessCommandLineArgs</strong></a>(cls, parser, args)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Override&nbsp;to&nbsp;process&nbsp;command-line&nbsp;arguments.<br>
71&nbsp;<br>
72We&nbsp;pass&nbsp;in&nbsp;parser&nbsp;so&nbsp;we&nbsp;can&nbsp;call&nbsp;parser.error().</tt></dd></dl>
73
74<hr>
75Data descriptors defined here:<br>
76<dl><dt><strong>__dict__</strong></dt>
77<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
78</dl>
79<dl><dt><strong>__weakref__</strong></dt>
80<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
81</dl>
82</td></tr></table> <p>
83<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
84<tr bgcolor="#ffc8d8">
85<td colspan=3 valign=bottom>&nbsp;<br>
86<font color="#000000" face="helvetica, arial"><a name="Command">class <strong>Command</strong></a>(<a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">ArgumentHandlerMixIn</a>)</font></td></tr>
87
88<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
89<td colspan=2><tt>An&nbsp;abstraction&nbsp;for&nbsp;things&nbsp;that&nbsp;run&nbsp;from&nbsp;the&nbsp;command-line.<br>&nbsp;</tt></td></tr>
90<tr><td>&nbsp;</td>
91<td width="100%"><dl><dt>Method resolution order:</dt>
92<dd><a href="telemetry.internal.util.command_line.html#Command">Command</a></dd>
93<dd><a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">ArgumentHandlerMixIn</a></dd>
94<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
95</dl>
96<hr>
97Methods defined here:<br>
98<dl><dt><a name="Command-Run"><strong>Run</strong></a>(self, args)</dt></dl>
99
100<hr>
101Class methods defined here:<br>
102<dl><dt><a name="Command-Description"><strong>Description</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
103
104<dl><dt><a name="Command-Name"><strong>Name</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
105
106<dl><dt><a name="Command-main"><strong>main</strong></a>(cls, args<font color="#909090">=None</font>)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Main&nbsp;method&nbsp;to&nbsp;run&nbsp;this&nbsp;command&nbsp;as&nbsp;a&nbsp;standalone&nbsp;script.</tt></dd></dl>
107
108<hr>
109Class methods inherited from <a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">ArgumentHandlerMixIn</a>:<br>
110<dl><dt><a name="Command-AddCommandLineArgs"><strong>AddCommandLineArgs</strong></a>(cls, parser)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Override&nbsp;to&nbsp;accept&nbsp;custom&nbsp;command-line&nbsp;arguments.</tt></dd></dl>
111
112<dl><dt><a name="Command-ProcessCommandLineArgs"><strong>ProcessCommandLineArgs</strong></a>(cls, parser, args)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Override&nbsp;to&nbsp;process&nbsp;command-line&nbsp;arguments.<br>
113&nbsp;<br>
114We&nbsp;pass&nbsp;in&nbsp;parser&nbsp;so&nbsp;we&nbsp;can&nbsp;call&nbsp;parser.error().</tt></dd></dl>
115
116<hr>
117Data descriptors inherited from <a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">ArgumentHandlerMixIn</a>:<br>
118<dl><dt><strong>__dict__</strong></dt>
119<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
120</dl>
121<dl><dt><strong>__weakref__</strong></dt>
122<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
123</dl>
124</td></tr></table> <p>
125<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
126<tr bgcolor="#ffc8d8">
127<td colspan=3 valign=bottom>&nbsp;<br>
128<font color="#000000" face="helvetica, arial"><a name="OptparseCommand">class <strong>OptparseCommand</strong></a>(<a href="telemetry.internal.util.command_line.html#Command">Command</a>)</font></td></tr>
129
130<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
131<td colspan=2><tt>#&nbsp;TODO:&nbsp;Convert&nbsp;everything&nbsp;to&nbsp;argparse.<br>&nbsp;</tt></td></tr>
132<tr><td>&nbsp;</td>
133<td width="100%"><dl><dt>Method resolution order:</dt>
134<dd><a href="telemetry.internal.util.command_line.html#OptparseCommand">OptparseCommand</a></dd>
135<dd><a href="telemetry.internal.util.command_line.html#Command">Command</a></dd>
136<dd><a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">ArgumentHandlerMixIn</a></dd>
137<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
138</dl>
139<hr>
140Methods defined here:<br>
141<dl><dt><a name="OptparseCommand-Run"><strong>Run</strong></a>(self, args)</dt></dl>
142
143<hr>
144Class methods defined here:<br>
145<dl><dt><a name="OptparseCommand-AddCommandLineArgs"><strong>AddCommandLineArgs</strong></a>(cls, parser, environment)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
146
147<dl><dt><a name="OptparseCommand-CreateParser"><strong>CreateParser</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
148
149<dl><dt><a name="OptparseCommand-ProcessCommandLineArgs"><strong>ProcessCommandLineArgs</strong></a>(cls, parser, args, environment)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
150
151<dl><dt><a name="OptparseCommand-main"><strong>main</strong></a>(cls, args<font color="#909090">=None</font>)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Main&nbsp;method&nbsp;to&nbsp;run&nbsp;this&nbsp;command&nbsp;as&nbsp;a&nbsp;standalone&nbsp;script.</tt></dd></dl>
152
153<hr>
154Data and other attributes defined here:<br>
155<dl><dt><strong>usage</strong> = ''</dl>
156
157<hr>
158Class methods inherited from <a href="telemetry.internal.util.command_line.html#Command">Command</a>:<br>
159<dl><dt><a name="OptparseCommand-Description"><strong>Description</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
160
161<dl><dt><a name="OptparseCommand-Name"><strong>Name</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
162
163<hr>
164Data descriptors inherited from <a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">ArgumentHandlerMixIn</a>:<br>
165<dl><dt><strong>__dict__</strong></dt>
166<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
167</dl>
168<dl><dt><strong>__weakref__</strong></dt>
169<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
170</dl>
171</td></tr></table> <p>
172<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
173<tr bgcolor="#ffc8d8">
174<td colspan=3 valign=bottom>&nbsp;<br>
175<font color="#000000" face="helvetica, arial"><a name="SubcommandCommand">class <strong>SubcommandCommand</strong></a>(<a href="telemetry.internal.util.command_line.html#Command">Command</a>)</font></td></tr>
176
177<tr bgcolor="#ffc8d8"><td rowspan=2><tt>&nbsp;&nbsp;&nbsp;</tt></td>
178<td colspan=2><tt>Combines&nbsp;Commands&nbsp;into&nbsp;one&nbsp;big&nbsp;command&nbsp;with&nbsp;sub-commands.<br>
179&nbsp;<br>
180E.g.&nbsp;"svn&nbsp;checkout",&nbsp;"svn&nbsp;update",&nbsp;and&nbsp;"svn&nbsp;commit"&nbsp;are&nbsp;separate&nbsp;sub-commands.<br>
181&nbsp;<br>
182Example&nbsp;usage:<br>
183&nbsp;&nbsp;class&nbsp;MyCommand(command_line.<a href="#SubcommandCommand">SubcommandCommand</a>):<br>
184&nbsp;&nbsp;&nbsp;&nbsp;commands&nbsp;=&nbsp;(Help,&nbsp;List,&nbsp;Run)<br>
185&nbsp;<br>
186&nbsp;&nbsp;if&nbsp;__name__&nbsp;==&nbsp;'__main__':<br>
187&nbsp;&nbsp;&nbsp;&nbsp;sys.exit(MyCommand.<a href="#SubcommandCommand-main">main</a>())<br>&nbsp;</tt></td></tr>
188<tr><td>&nbsp;</td>
189<td width="100%"><dl><dt>Method resolution order:</dt>
190<dd><a href="telemetry.internal.util.command_line.html#SubcommandCommand">SubcommandCommand</a></dd>
191<dd><a href="telemetry.internal.util.command_line.html#Command">Command</a></dd>
192<dd><a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">ArgumentHandlerMixIn</a></dd>
193<dd><a href="__builtin__.html#object">__builtin__.object</a></dd>
194</dl>
195<hr>
196Methods defined here:<br>
197<dl><dt><a name="SubcommandCommand-Run"><strong>Run</strong></a>(self, args)</dt></dl>
198
199<hr>
200Class methods defined here:<br>
201<dl><dt><a name="SubcommandCommand-AddCommandLineArgs"><strong>AddCommandLineArgs</strong></a>(cls, parser)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
202
203<dl><dt><a name="SubcommandCommand-ProcessCommandLineArgs"><strong>ProcessCommandLineArgs</strong></a>(cls, parser, args)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
204
205<hr>
206Data and other attributes defined here:<br>
207<dl><dt><strong>commands</strong> = ()</dl>
208
209<hr>
210Class methods inherited from <a href="telemetry.internal.util.command_line.html#Command">Command</a>:<br>
211<dl><dt><a name="SubcommandCommand-Description"><strong>Description</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
212
213<dl><dt><a name="SubcommandCommand-Name"><strong>Name</strong></a>(cls)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt></dl>
214
215<dl><dt><a name="SubcommandCommand-main"><strong>main</strong></a>(cls, args<font color="#909090">=None</font>)<font color="#909090"><font face="helvetica, arial"> from <a href="__builtin__.html#type">__builtin__.type</a></font></font></dt><dd><tt>Main&nbsp;method&nbsp;to&nbsp;run&nbsp;this&nbsp;command&nbsp;as&nbsp;a&nbsp;standalone&nbsp;script.</tt></dd></dl>
216
217<hr>
218Data descriptors inherited from <a href="telemetry.internal.util.command_line.html#ArgumentHandlerMixIn">ArgumentHandlerMixIn</a>:<br>
219<dl><dt><strong>__dict__</strong></dt>
220<dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
221</dl>
222<dl><dt><strong>__weakref__</strong></dt>
223<dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
224</dl>
225</td></tr></table></td></tr></table><p>
226<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
227<tr bgcolor="#eeaa77">
228<td colspan=3 valign=bottom>&nbsp;<br>
229<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
230
231<tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
232<td width="100%"><dl><dt><a name="-GetMostLikelyMatchedObject"><strong>GetMostLikelyMatchedObject</strong></a>(objects, target_name, name_func<font color="#909090">=&lt;function &lt;lambda&gt;&gt;</font>, matched_score_threshold<font color="#909090">=0.4</font>)</dt><dd><tt>Matches&nbsp;objects&nbsp;whose&nbsp;names&nbsp;are&nbsp;most&nbsp;likely&nbsp;matched&nbsp;with&nbsp;target.<br>
233&nbsp;<br>
234Args:<br>
235&nbsp;&nbsp;objects:&nbsp;list&nbsp;of&nbsp;objects&nbsp;to&nbsp;match.<br>
236&nbsp;&nbsp;target_name:&nbsp;name&nbsp;to&nbsp;match.<br>
237&nbsp;&nbsp;name_func:&nbsp;function&nbsp;to&nbsp;get&nbsp;<a href="__builtin__.html#object">object</a>&nbsp;name&nbsp;to&nbsp;match.&nbsp;Default&nbsp;bypass.<br>
238&nbsp;&nbsp;matched_score_threshold:&nbsp;threshold&nbsp;of&nbsp;likelihood&nbsp;to&nbsp;match.<br>
239&nbsp;<br>
240Returns:<br>
241&nbsp;&nbsp;A&nbsp;list&nbsp;of&nbsp;objects&nbsp;whose&nbsp;names&nbsp;are&nbsp;likely&nbsp;target_name.</tt></dd></dl>
242</td></tr></table>
243</body></html>