/usr/share/doc/python-logilab-common/apidoc/logilab.common.optparser-pysrc.html is in python-logilab-common 1.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | <?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>logilab.common.optparser</title>
<link rel="stylesheet" href="epydoc.css" type="text/css" />
<script type="text/javascript" src="epydoc.js"></script>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th> <a
href="logilab.common-module.html">Home</a> </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
>Logilab's common library</th>
</tr></table></th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<span class="breadcrumbs">
Package logilab ::
<a href="logilab.common-module.html">Package common</a> ::
Module optparser
</span>
</td>
<td>
<table cellpadding="0" cellspacing="0">
<!-- hide/show private -->
<tr><td align="right"><span class="options"
>[<a href="frames.html" target="_top">frames</a
>] | <a href="logilab.common.optparser-pysrc.html"
target="_top">no frames</a>]</span></td></tr>
</table>
</td>
</tr>
</table>
<h1 class="epydoc">Source Code for <a href="logilab.common.optparser-module.html">Module logilab.common.optparser</a></h1>
<pre class="py-src">
<a name="L1"></a><tt class="py-lineno"> 1</tt> <tt class="py-line"><tt class="py-comment"># -*- coding: utf-8 -*-</tt> </tt>
<a name="L2"></a><tt class="py-lineno"> 2</tt> <tt class="py-line"><tt class="py-comment"># copyright 2003-2011 LOGILAB S.A. (Paris, FRANCE), all rights reserved.</tt> </tt>
<a name="L3"></a><tt class="py-lineno"> 3</tt> <tt class="py-line"><tt class="py-comment"># contact http://www.logilab.fr/ -- mailto:contact@logilab.fr</tt> </tt>
<a name="L4"></a><tt class="py-lineno"> 4</tt> <tt class="py-line"><tt class="py-comment">#</tt> </tt>
<a name="L5"></a><tt class="py-lineno"> 5</tt> <tt class="py-line"><tt class="py-comment"># This file is part of logilab-common.</tt> </tt>
<a name="L6"></a><tt class="py-lineno"> 6</tt> <tt class="py-line"><tt class="py-comment">#</tt> </tt>
<a name="L7"></a><tt class="py-lineno"> 7</tt> <tt class="py-line"><tt class="py-comment"># logilab-common is free software: you can redistribute it and/or modify it under</tt> </tt>
<a name="L8"></a><tt class="py-lineno"> 8</tt> <tt class="py-line"><tt class="py-comment"># the terms of the GNU Lesser General Public License as published by the Free</tt> </tt>
<a name="L9"></a><tt class="py-lineno"> 9</tt> <tt class="py-line"><tt class="py-comment"># Software Foundation, either version 2.1 of the License, or (at your option) any</tt> </tt>
<a name="L10"></a><tt class="py-lineno">10</tt> <tt class="py-line"><tt class="py-comment"># later version.</tt> </tt>
<a name="L11"></a><tt class="py-lineno">11</tt> <tt class="py-line"><tt class="py-comment">#</tt> </tt>
<a name="L12"></a><tt class="py-lineno">12</tt> <tt class="py-line"><tt class="py-comment"># logilab-common is distributed in the hope that it will be useful, but WITHOUT</tt> </tt>
<a name="L13"></a><tt class="py-lineno">13</tt> <tt class="py-line"><tt class="py-comment"># ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS</tt> </tt>
<a name="L14"></a><tt class="py-lineno">14</tt> <tt class="py-line"><tt class="py-comment"># FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more</tt> </tt>
<a name="L15"></a><tt class="py-lineno">15</tt> <tt class="py-line"><tt class="py-comment"># details.</tt> </tt>
<a name="L16"></a><tt class="py-lineno">16</tt> <tt class="py-line"><tt class="py-comment">#</tt> </tt>
<a name="L17"></a><tt class="py-lineno">17</tt> <tt class="py-line"><tt class="py-comment"># You should have received a copy of the GNU Lesser General Public License along</tt> </tt>
<a name="L18"></a><tt class="py-lineno">18</tt> <tt class="py-line"><tt class="py-comment"># with logilab-common. If not, see <http://www.gnu.org/licenses/>.</tt> </tt>
<a name="L19"></a><tt class="py-lineno">19</tt> <tt class="py-line"><tt class="py-docstring">"""Extend OptionParser with commands.</tt> </tt>
<a name="L20"></a><tt class="py-lineno">20</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L21"></a><tt class="py-lineno">21</tt> <tt class="py-line"><tt class="py-docstring">Example:</tt> </tt>
<a name="L22"></a><tt class="py-lineno">22</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L23"></a><tt class="py-lineno">23</tt> <tt class="py-line"><tt class="py-docstring">>>> parser = OptionParser()</tt> </tt>
<a name="L24"></a><tt class="py-lineno">24</tt> <tt class="py-line"><tt class="py-docstring">>>> parser.usage = '%prog COMMAND [options] <arg> ...'</tt> </tt>
<a name="L25"></a><tt class="py-lineno">25</tt> <tt class="py-line"><tt class="py-docstring">>>> parser.add_command('build', 'mymod.build')</tt> </tt>
<a name="L26"></a><tt class="py-lineno">26</tt> <tt class="py-line"><tt class="py-docstring">>>> parser.add_command('clean', run_clean, add_opt_clean)</tt> </tt>
<a name="L27"></a><tt class="py-lineno">27</tt> <tt class="py-line"><tt class="py-docstring">>>> run, options, args = parser.parse_command(sys.argv[1:])</tt> </tt>
<a name="L28"></a><tt class="py-lineno">28</tt> <tt class="py-line"><tt class="py-docstring">>>> return run(options, args[1:])</tt> </tt>
<a name="L29"></a><tt class="py-lineno">29</tt> <tt class="py-line"><tt class="py-docstring"></tt> </tt>
<a name="L30"></a><tt class="py-lineno">30</tt> <tt class="py-line"><tt class="py-docstring">With mymod.build that defines two functions run and add_options</tt> </tt>
<a name="L31"></a><tt class="py-lineno">31</tt> <tt class="py-line"><tt class="py-docstring">"""</tt> </tt>
<a name="L32"></a><tt class="py-lineno">32</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">__future__</tt> <tt class="py-keyword">import</tt> <tt class="py-name">print_function</tt> </tt>
<a name="L33"></a><tt class="py-lineno">33</tt> <tt class="py-line"> </tt>
<a name="L34"></a><tt class="py-lineno">34</tt> <tt class="py-line"><tt class="py-name">__docformat__</tt> <tt class="py-op">=</tt> <tt class="py-string">"restructuredtext en"</tt> </tt>
<a name="L35"></a><tt class="py-lineno">35</tt> <tt class="py-line"> </tt>
<a name="L36"></a><tt class="py-lineno">36</tt> <tt class="py-line"><tt class="py-keyword">from</tt> <tt class="py-name">warnings</tt> <tt class="py-keyword">import</tt> <tt id="link-0" class="py-name" targets="Method logilab.common.deprecation.DeprecationManager.warn()=logilab.common.deprecation.DeprecationManager-class.html#warn"><a title="logilab.common.deprecation.DeprecationManager.warn" class="py-name" href="#" onclick="return doclink('link-0', 'warn', 'link-0');">warn</a></tt> </tt>
<a name="L37"></a><tt class="py-lineno">37</tt> <tt class="py-line"><tt id="link-1" class="py-name"><a title="logilab.common.deprecation.DeprecationManager.warn" class="py-name" href="#" onclick="return doclink('link-1', 'warn', 'link-0');">warn</a></tt><tt class="py-op">(</tt><tt class="py-string">'lgc.optparser module is deprecated, use lgc.clcommands instead'</tt><tt class="py-op">,</tt> <tt class="py-name">DeprecationWarning</tt><tt class="py-op">,</tt> </tt>
<a name="L38"></a><tt class="py-lineno">38</tt> <tt class="py-line"> <tt class="py-name">stacklevel</tt><tt class="py-op">=</tt><tt class="py-number">2</tt><tt class="py-op">)</tt> </tt>
<a name="L39"></a><tt class="py-lineno">39</tt> <tt class="py-line"> </tt>
<a name="L40"></a><tt class="py-lineno">40</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">sys</tt> </tt>
<a name="L41"></a><tt class="py-lineno">41</tt> <tt class="py-line"><tt class="py-keyword">import</tt> <tt class="py-name">optparse</tt> </tt>
<a name="L42"></a><tt class="py-lineno">42</tt> <tt class="py-line"> </tt>
<a name="OptionParser"></a><div id="OptionParser-def"><a name="L43"></a><tt class="py-lineno">43</tt> <a class="py-toggle" href="#" id="OptionParser-toggle" onclick="return toggle('OptionParser');">-</a><tt class="py-line"><tt class="py-keyword">class</tt> <a class="py-def-name" href="logilab.common.optparser.OptionParser-class.html">OptionParser</a><tt class="py-op">(</tt><tt class="py-base-class">optparse</tt><tt class="py-op">.</tt><tt class="py-base-class">OptionParser</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="OptionParser-collapsed" style="display:none;" pad="++" indent="++++"></div><div id="OptionParser-expanded"><a name="L44"></a><tt class="py-lineno">44</tt> <tt class="py-line"> </tt>
<a name="OptionParser.__init__"></a><div id="OptionParser.__init__-def"><a name="L45"></a><tt class="py-lineno">45</tt> <a class="py-toggle" href="#" id="OptionParser.__init__-toggle" onclick="return toggle('OptionParser.__init__');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="logilab.common.optparser.OptionParser-class.html#__init__">__init__</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-op">*</tt><tt class="py-param">args</tt><tt class="py-op">,</tt> <tt class="py-op">**</tt><tt class="py-param">kwargs</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="OptionParser.__init__-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="OptionParser.__init__-expanded"><a name="L46"></a><tt class="py-lineno">46</tt> <tt class="py-line"> <tt class="py-name">optparse</tt><tt class="py-op">.</tt><tt id="link-2" class="py-name" targets="Class logilab.common.optik_ext.OptionParser=logilab.common.optik_ext.OptionParser-class.html,Class logilab.common.optparser.OptionParser=logilab.common.optparser.OptionParser-class.html"><a title="logilab.common.optik_ext.OptionParser
logilab.common.optparser.OptionParser" class="py-name" href="#" onclick="return doclink('link-2', 'OptionParser', 'link-2');">OptionParser</a></tt><tt class="py-op">.</tt><tt id="link-3" class="py-name" targets="Method logilab.common.cache.Cache.__init__()=logilab.common.cache.Cache-class.html#__init__,Method logilab.common.changelog.ChangeLog.__init__()=logilab.common.changelog.ChangeLog-class.html#__init__,Method logilab.common.changelog.ChangeLogEntry.__init__()=logilab.common.changelog.ChangeLogEntry-class.html#__init__,Method logilab.common.clcommands.Command.__init__()=logilab.common.clcommands.Command-class.html#__init__,Method logilab.common.clcommands.CommandLine.__init__()=logilab.common.clcommands.CommandLine-class.html#__init__,Method logilab.common.configuration.Configuration.__init__()=logilab.common.configuration.Configuration-class.html#__init__,Method logilab.common.configuration.ConfigurationMixIn.__init__()=logilab.common.configuration.ConfigurationMixIn-class.html#__init__,Method logilab.common.configuration.OptionsManager2ConfigurationAdapter.__init__()=logilab.common.configuration.OptionsManager2ConfigurationAdapter-class.html#__init__,Method logilab.common.configuration.OptionsManagerMixIn.__init__()=logilab.common.configuration.OptionsManagerMixIn-class.html#__init__,Method logilab.common.configuration.OptionsProviderMixIn.__init__()=logilab.common.configuration.OptionsProviderMixIn-class.html#__init__,Method logilab.common.debugger.Debugger.__init__()=logilab.common.debugger.Debugger-class.html#__init__,Method logilab.common.decorators.cached_decorator.__init__()=logilab.common.decorators.cached_decorator-class.html#__init__,Method logilab.common.decorators.cachedproperty.__init__()=logilab.common.decorators.cachedproperty-class.html#__init__,Method logilab.common.decorators.classproperty.__init__()=logilab.common.decorators.classproperty-class.html#__init__,Method logilab.common.decorators.iclassmethod.__init__()=logilab.common.decorators.iclassmethod-class.html#__init__,Method logilab.common.decorators.wproperty.__init__()=logilab.common.decorators.wproperty-class.html#__init__,Method logilab.common.deprecation.DeprecationManager.__init__()=logilab.common.deprecation.DeprecationManager-class.html#__init__,Method logilab.common.deprecation.DeprecationWrapper.__init__()=logilab.common.deprecation.DeprecationWrapper-class.html#__init__,Method logilab.common.dictattr.__init__()=logilab.common.dictattr-class.html#__init__,Method logilab.common.fileutils.ProtectedFile.__init__()=logilab.common.fileutils.ProtectedFile-class.html#__init__,Method logilab.common.graph.DotBackend.__init__()=logilab.common.graph.DotBackend-class.html#__init__,Method logilab.common.graph.GraphGenerator.__init__()=logilab.common.graph.GraphGenerator-class.html#__init__,Method logilab.common.logging_ext.ColorFormatter.__init__()=logilab.common.logging_ext.ColorFormatter-class.html#__init__,Method logilab.common.modutils.LazyObject.__init__()=logilab.common.modutils.LazyObject-class.html#__init__,Method logilab.common.optik_ext.Option.__init__()=logilab.common.optik_ext.Option-class.html#__init__,Method logilab.common.optik_ext.OptionParser.__init__()=logilab.common.optik_ext.OptionParser-class.html#__init__,Method logilab.common.optparser.OptionParser.__init__()=logilab.common.optparser.OptionParser-class.html#__init__,Method logilab.common.proc.MemorySentinel.__init__()=logilab.common.proc.MemorySentinel-class.html#__init__,Method logilab.common.proc.ProcInfo.__init__()=logilab.common.proc.ProcInfo-class.html#__init__,Method logilab.common.proc.ProcInfoLoader.__init__()=logilab.common.proc.ProcInfoLoader-class.html#__init__,Method logilab.common.proc.ResourceController.__init__()=logilab.common.proc.ResourceController-class.html#__init__,Method logilab.common.registry.MultiPredicate.__init__()=logilab.common.registry.MultiPredicate-class.html#__init__,Method logilab.common.registry.NoSelectableObject.__init__()=logilab.common.registry.NoSelectableObject-class.html#__init__,Method logilab.common.registry.NotPredicate.__init__()=logilab.common.registry.NotPredicate-class.html#__init__,Method logilab.common.registry.RegistrableInstance.__init__()=logilab.common.registry.RegistrableInstance-class.html#__init__,Method logilab.common.registry.Registry.__init__()=logilab.common.registry.Registry-class.html#__init__,Method logilab.common.registry.RegistryStore.__init__()=logilab.common.registry.RegistryStore-class.html#__init__,Method logilab.common.registry.traced_selection.__init__()=logilab.common.registry.traced_selection-class.html#__init__,Method logilab.common.registry.yes.__init__()=logilab.common.registry.yes-class.html#__init__,Method logilab.common.shellutils.ProgressBar.__init__()=logilab.common.shellutils.ProgressBar-class.html#__init__,Method logilab.common.shellutils.RawInput.__init__()=logilab.common.shellutils.RawInput-class.html#__init__,Method logilab.common.shellutils.progress.__init__()=logilab.common.shellutils.progress-class.html#__init__,Method logilab.common.shellutils.pushd.__init__()=logilab.common.shellutils.pushd-class.html#__init__,Method logilab.common.sphinxutils.ModuleGenerator.__init__()=logilab.common.sphinxutils.ModuleGenerator-class.html#__init__,Method logilab.common.table.Table.__init__()=logilab.common.table.Table-class.html#__init__,Method logilab.common.table.TableCellRenderer.__init__()=logilab.common.table.TableCellRenderer-class.html#__init__,Method logilab.common.table.TableStyle.__init__()=logilab.common.table.TableStyle-class.html#__init__,Method logilab.common.table.TableStyleSheet.__init__()=logilab.common.table.TableStyleSheet-class.html#__init__,Method logilab.common.table.TableWriter.__init__()=logilab.common.table.TableWriter-class.html#__init__,Method logilab.common.tasksqueue.Task.__init__()=logilab.common.tasksqueue.Task-class.html#__init__,Method logilab.common.tempattr.__init__()=logilab.common.tempattr-class.html#__init__,Method logilab.common.tree.BinaryNode.__init__()=logilab.common.tree.BinaryNode-class.html#__init__,Method logilab.common.tree.ListNode.__init__()=logilab.common.tree.ListNode-class.html#__init__,Method logilab.common.tree.Node.__init__()=logilab.common.tree.Node-class.html#__init__,Method logilab.common.tree.PostfixedDepthFirstIterator.__init__()=logilab.common.tree.PostfixedDepthFirstIterator-class.html#__init__,Method logilab.common.tree.PrefixedDepthFirstIterator.__init__()=logilab.common.tree.PrefixedDepthFirstIterator-class.html#__init__,Method logilab.common.umessage.UMessage.__init__()=logilab.common.umessage.UMessage-class.html#__init__,Method logilab.common.ureports.html_writer.HTMLWriter.__init__()=logilab.common.ureports.html_writer.HTMLWriter-class.html#__init__,Method logilab.common.ureports.nodes.BaseComponent.__init__()=logilab.common.ureports.nodes.BaseComponent-class.html#__init__,Method logilab.common.ureports.nodes.BaseLayout.__init__()=logilab.common.ureports.nodes.BaseLayout-class.html#__init__,Method logilab.common.ureports.nodes.Image.__init__()=logilab.common.ureports.nodes.Image-class.html#__init__,Method logilab.common.ureports.nodes.Link.__init__()=logilab.common.ureports.nodes.Link-class.html#__init__,Method logilab.common.ureports.nodes.Section.__init__()=logilab.common.ureports.nodes.Section-class.html#__init__,Method logilab.common.ureports.nodes.Table.__init__()=logilab.common.ureports.nodes.Table-class.html#__init__,Method logilab.common.ureports.nodes.Text.__init__()=logilab.common.ureports.nodes.Text-class.html#__init__,Method logilab.common.urllib2ext.HTTPGssapiAuthHandler.__init__()=logilab.common.urllib2ext.HTTPGssapiAuthHandler-class.html#__init__,Method logilab.common.vcgutils.VCGPrinter.__init__()=logilab.common.vcgutils.VCGPrinter-class.html#__init__,Method logilab.common.visitor.FilteredIterator.__init__()=logilab.common.visitor.FilteredIterator-class.html#__init__,Method logilab.common.visitor.Visitor.__init__()=logilab.common.visitor.Visitor-class.html#__init__"><a title="logilab.common.cache.Cache.__init__
logilab.common.changelog.ChangeLog.__init__
logilab.common.changelog.ChangeLogEntry.__init__
logilab.common.clcommands.Command.__init__
logilab.common.clcommands.CommandLine.__init__
logilab.common.configuration.Configuration.__init__
logilab.common.configuration.ConfigurationMixIn.__init__
logilab.common.configuration.OptionsManager2ConfigurationAdapter.__init__
logilab.common.configuration.OptionsManagerMixIn.__init__
logilab.common.configuration.OptionsProviderMixIn.__init__
logilab.common.debugger.Debugger.__init__
logilab.common.decorators.cached_decorator.__init__
logilab.common.decorators.cachedproperty.__init__
logilab.common.decorators.classproperty.__init__
logilab.common.decorators.iclassmethod.__init__
logilab.common.decorators.wproperty.__init__
logilab.common.deprecation.DeprecationManager.__init__
logilab.common.deprecation.DeprecationWrapper.__init__
logilab.common.dictattr.__init__
logilab.common.fileutils.ProtectedFile.__init__
logilab.common.graph.DotBackend.__init__
logilab.common.graph.GraphGenerator.__init__
logilab.common.logging_ext.ColorFormatter.__init__
logilab.common.modutils.LazyObject.__init__
logilab.common.optik_ext.Option.__init__
logilab.common.optik_ext.OptionParser.__init__
logilab.common.optparser.OptionParser.__init__
logilab.common.proc.MemorySentinel.__init__
logilab.common.proc.ProcInfo.__init__
logilab.common.proc.ProcInfoLoader.__init__
logilab.common.proc.ResourceController.__init__
logilab.common.registry.MultiPredicate.__init__
logilab.common.registry.NoSelectableObject.__init__
logilab.common.registry.NotPredicate.__init__
logilab.common.registry.RegistrableInstance.__init__
logilab.common.registry.Registry.__init__
logilab.common.registry.RegistryStore.__init__
logilab.common.registry.traced_selection.__init__
logilab.common.registry.yes.__init__
logilab.common.shellutils.ProgressBar.__init__
logilab.common.shellutils.RawInput.__init__
logilab.common.shellutils.progress.__init__
logilab.common.shellutils.pushd.__init__
logilab.common.sphinxutils.ModuleGenerator.__init__
logilab.common.table.Table.__init__
logilab.common.table.TableCellRenderer.__init__
logilab.common.table.TableStyle.__init__
logilab.common.table.TableStyleSheet.__init__
logilab.common.table.TableWriter.__init__
logilab.common.tasksqueue.Task.__init__
logilab.common.tempattr.__init__
logilab.common.tree.BinaryNode.__init__
logilab.common.tree.ListNode.__init__
logilab.common.tree.Node.__init__
logilab.common.tree.PostfixedDepthFirstIterator.__init__
logilab.common.tree.PrefixedDepthFirstIterator.__init__
logilab.common.umessage.UMessage.__init__
logilab.common.ureports.html_writer.HTMLWriter.__init__
logilab.common.ureports.nodes.BaseComponent.__init__
logilab.common.ureports.nodes.BaseLayout.__init__
logilab.common.ureports.nodes.Image.__init__
logilab.common.ureports.nodes.Link.__init__
logilab.common.ureports.nodes.Section.__init__
logilab.common.ureports.nodes.Table.__init__
logilab.common.ureports.nodes.Text.__init__
logilab.common.urllib2ext.HTTPGssapiAuthHandler.__init__
logilab.common.vcgutils.VCGPrinter.__init__
logilab.common.visitor.FilteredIterator.__init__
logilab.common.visitor.Visitor.__init__" class="py-name" href="#" onclick="return doclink('link-3', '__init__', 'link-3');">__init__</a></tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">,</tt> <tt class="py-op">*</tt><tt class="py-name">args</tt><tt class="py-op">,</tt> <tt class="py-op">**</tt><tt class="py-name">kwargs</tt><tt class="py-op">)</tt> </tt>
<a name="L47"></a><tt class="py-lineno">47</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_commands</tt> <tt class="py-op">=</tt> <tt class="py-op">{</tt><tt class="py-op">}</tt> </tt>
<a name="L48"></a><tt class="py-lineno">48</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-4" class="py-name" targets="Variable logilab.common.clcommands.Command.min_args=logilab.common.clcommands.Command-class.html#min_args"><a title="logilab.common.clcommands.Command.min_args" class="py-name" href="#" onclick="return doclink('link-4', 'min_args', 'link-4');">min_args</a></tt><tt class="py-op">,</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-5" class="py-name" targets="Variable logilab.common.clcommands.Command.max_args=logilab.common.clcommands.Command-class.html#max_args"><a title="logilab.common.clcommands.Command.max_args" class="py-name" href="#" onclick="return doclink('link-5', 'max_args', 'link-5');">max_args</a></tt> <tt class="py-op">=</tt> <tt class="py-number">0</tt><tt class="py-op">,</tt> <tt class="py-number">1</tt> </tt>
</div><a name="L49"></a><tt class="py-lineno">49</tt> <tt class="py-line"> </tt>
<a name="OptionParser.add_command"></a><div id="OptionParser.add_command-def"><a name="L50"></a><tt class="py-lineno">50</tt> <a class="py-toggle" href="#" id="OptionParser.add_command-toggle" onclick="return toggle('OptionParser.add_command');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="logilab.common.optparser.OptionParser-class.html#add_command">add_command</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">name</tt><tt class="py-op">,</tt> <tt class="py-param">mod_or_funcs</tt><tt class="py-op">,</tt> <tt class="py-param">help</tt><tt class="py-op">=</tt><tt class="py-string">''</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="OptionParser.add_command-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="OptionParser.add_command-expanded"><a name="L51"></a><tt class="py-lineno">51</tt> <tt class="py-line"> <tt class="py-docstring">"""name of the command, name of module or tuple of functions</tt> </tt>
<a name="L52"></a><tt class="py-lineno">52</tt> <tt class="py-line"><tt class="py-docstring"> (run, add_options)</tt> </tt>
<a name="L53"></a><tt class="py-lineno">53</tt> <tt class="py-line"><tt class="py-docstring"> """</tt> </tt>
<a name="L54"></a><tt class="py-lineno">54</tt> <tt class="py-line"> <tt class="py-keyword">assert</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">mod_or_funcs</tt><tt class="py-op">,</tt> <tt class="py-name">str</tt><tt class="py-op">)</tt> <tt class="py-keyword">or</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">mod_or_funcs</tt><tt class="py-op">,</tt> <tt class="py-name">tuple</tt><tt class="py-op">)</tt><tt class="py-op">,</tt> \ </tt>
<a name="L55"></a><tt class="py-lineno">55</tt> <tt class="py-line"> <tt class="py-string">"mod_or_funcs has to be a module name or a tuple of functions"</tt> </tt>
<a name="L56"></a><tt class="py-lineno">56</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_commands</tt><tt class="py-op">[</tt><tt id="link-6" class="py-name" targets="Variable logilab.common.clcommands.Command.name=logilab.common.clcommands.Command-class.html#name,Variable logilab.common.clcommands.ListCommandsCommand.name=logilab.common.clcommands.ListCommandsCommand-class.html#name,Variable logilab.common.configuration.OptionsProviderMixIn.name=logilab.common.configuration.OptionsProviderMixIn-class.html#name,Method logilab.common.proc.ProcInfo.name()=logilab.common.proc.ProcInfo-class.html#name"><a title="logilab.common.clcommands.Command.name
logilab.common.clcommands.ListCommandsCommand.name
logilab.common.configuration.OptionsProviderMixIn.name
logilab.common.proc.ProcInfo.name" class="py-name" href="#" onclick="return doclink('link-6', 'name', 'link-6');">name</a></tt><tt class="py-op">]</tt> <tt class="py-op">=</tt> <tt class="py-op">(</tt><tt class="py-name">mod_or_funcs</tt><tt class="py-op">,</tt> <tt id="link-7" class="py-name" targets="Method logilab.common.configuration.OptionsManagerMixIn.help()=logilab.common.configuration.OptionsManagerMixIn-class.html#help"><a title="logilab.common.configuration.OptionsManagerMixIn.help" class="py-name" href="#" onclick="return doclink('link-7', 'help', 'link-7');">help</a></tt><tt class="py-op">)</tt> </tt>
</div><a name="L57"></a><tt class="py-lineno">57</tt> <tt class="py-line"> </tt>
<a name="OptionParser.print_main_help"></a><div id="OptionParser.print_main_help-def"><a name="L58"></a><tt class="py-lineno">58</tt> <a class="py-toggle" href="#" id="OptionParser.print_main_help-toggle" onclick="return toggle('OptionParser.print_main_help');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="logilab.common.optparser.OptionParser-class.html#print_main_help">print_main_help</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="OptionParser.print_main_help-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="OptionParser.print_main_help-expanded"><a name="L59"></a><tt class="py-lineno">59</tt> <tt class="py-line"> <tt class="py-name">optparse</tt><tt class="py-op">.</tt><tt id="link-8" class="py-name"><a title="logilab.common.optik_ext.OptionParser
logilab.common.optparser.OptionParser" class="py-name" href="#" onclick="return doclink('link-8', 'OptionParser', 'link-2');">OptionParser</a></tt><tt class="py-op">.</tt><tt class="py-name">print_help</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt> </tt>
<a name="L60"></a><tt class="py-lineno">60</tt> <tt class="py-line"> <tt class="py-keyword">print</tt><tt class="py-op">(</tt><tt class="py-string">'\ncommands:'</tt><tt class="py-op">)</tt> </tt>
<a name="L61"></a><tt class="py-lineno">61</tt> <tt class="py-line"> <tt class="py-keyword">for</tt> <tt class="py-name">cmdname</tt><tt class="py-op">,</tt> <tt class="py-op">(</tt><tt class="py-name">_</tt><tt class="py-op">,</tt> <tt id="link-9" class="py-name"><a title="logilab.common.configuration.OptionsManagerMixIn.help" class="py-name" href="#" onclick="return doclink('link-9', 'help', 'link-7');">help</a></tt><tt class="py-op">)</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_commands</tt><tt class="py-op">.</tt><tt class="py-name">items</tt><tt class="py-op">(</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L62"></a><tt class="py-lineno">62</tt> <tt class="py-line"> <tt class="py-keyword">print</tt><tt class="py-op">(</tt><tt class="py-string">'% 10s - %s'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">cmdname</tt><tt class="py-op">,</tt> <tt id="link-10" class="py-name"><a title="logilab.common.configuration.OptionsManagerMixIn.help" class="py-name" href="#" onclick="return doclink('link-10', 'help', 'link-7');">help</a></tt><tt class="py-op">)</tt><tt class="py-op">)</tt> </tt>
</div><a name="L63"></a><tt class="py-lineno">63</tt> <tt class="py-line"> </tt>
<a name="OptionParser.parse_command"></a><div id="OptionParser.parse_command-def"><a name="L64"></a><tt class="py-lineno">64</tt> <a class="py-toggle" href="#" id="OptionParser.parse_command-toggle" onclick="return toggle('OptionParser.parse_command');">-</a><tt class="py-line"> <tt class="py-keyword">def</tt> <a class="py-def-name" href="logilab.common.optparser.OptionParser-class.html#parse_command">parse_command</a><tt class="py-op">(</tt><tt class="py-param">self</tt><tt class="py-op">,</tt> <tt class="py-param">args</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
</div><div id="OptionParser.parse_command-collapsed" style="display:none;" pad="++" indent="++++++++"></div><div id="OptionParser.parse_command-expanded"><a name="L65"></a><tt class="py-lineno">65</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">)</tt> <tt class="py-op">==</tt> <tt class="py-number">0</tt><tt class="py-op">:</tt> </tt>
<a name="L66"></a><tt class="py-lineno">66</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-11" class="py-name" targets="Method logilab.common.optparser.OptionParser.print_main_help()=logilab.common.optparser.OptionParser-class.html#print_main_help"><a title="logilab.common.optparser.OptionParser.print_main_help" class="py-name" href="#" onclick="return doclink('link-11', 'print_main_help', 'link-11');">print_main_help</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L67"></a><tt class="py-lineno">67</tt> <tt class="py-line"> <tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">exit</tt><tt class="py-op">(</tt><tt class="py-number">1</tt><tt class="py-op">)</tt> </tt>
<a name="L68"></a><tt class="py-lineno">68</tt> <tt class="py-line"> <tt class="py-name">cmd</tt> <tt class="py-op">=</tt> <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">0</tt><tt class="py-op">]</tt> </tt>
<a name="L69"></a><tt class="py-lineno">69</tt> <tt class="py-line"> <tt class="py-name">args</tt> <tt class="py-op">=</tt> <tt class="py-name">args</tt><tt class="py-op">[</tt><tt class="py-number">1</tt><tt class="py-op">:</tt><tt class="py-op">]</tt> </tt>
<a name="L70"></a><tt class="py-lineno">70</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">cmd</tt> <tt class="py-keyword">not</tt> <tt class="py-keyword">in</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_commands</tt><tt class="py-op">:</tt> </tt>
<a name="L71"></a><tt class="py-lineno">71</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">cmd</tt> <tt class="py-keyword">in</tt> <tt class="py-op">(</tt><tt class="py-string">'-h'</tt><tt class="py-op">,</tt> <tt class="py-string">'--help'</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L72"></a><tt class="py-lineno">72</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-12" class="py-name"><a title="logilab.common.optparser.OptionParser.print_main_help" class="py-name" href="#" onclick="return doclink('link-12', 'print_main_help', 'link-11');">print_main_help</a></tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L73"></a><tt class="py-lineno">73</tt> <tt class="py-line"> <tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">exit</tt><tt class="py-op">(</tt><tt class="py-number">0</tt><tt class="py-op">)</tt> </tt>
<a name="L74"></a><tt class="py-lineno">74</tt> <tt class="py-line"> <tt class="py-keyword">elif</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">version</tt> <tt class="py-keyword">is</tt> <tt class="py-keyword">not</tt> <tt class="py-name">None</tt> <tt class="py-keyword">and</tt> <tt class="py-name">cmd</tt> <tt class="py-op">==</tt> <tt class="py-string">"--version"</tt><tt class="py-op">:</tt> </tt>
<a name="L75"></a><tt class="py-lineno">75</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">print_version</tt><tt class="py-op">(</tt><tt class="py-op">)</tt> </tt>
<a name="L76"></a><tt class="py-lineno">76</tt> <tt class="py-line"> <tt class="py-name">sys</tt><tt class="py-op">.</tt><tt class="py-name">exit</tt><tt class="py-op">(</tt><tt class="py-number">0</tt><tt class="py-op">)</tt> </tt>
<a name="L77"></a><tt class="py-lineno">77</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-13" class="py-name" targets="Variable logilab.common.registry.Registry.error=logilab.common.registry.Registry-class.html#error,Variable logilab.common.registry.RegistryStore.error=logilab.common.registry.RegistryStore-class.html#error"><a title="logilab.common.registry.Registry.error
logilab.common.registry.RegistryStore.error" class="py-name" href="#" onclick="return doclink('link-13', 'error', 'link-13');">error</a></tt><tt class="py-op">(</tt><tt class="py-string">'unknown command'</tt><tt class="py-op">)</tt> </tt>
<a name="L78"></a><tt class="py-lineno">78</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">prog</tt> <tt class="py-op">=</tt> <tt class="py-string">'%s %s'</tt> <tt class="py-op">%</tt> <tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">prog</tt><tt class="py-op">,</tt> <tt class="py-name">cmd</tt><tt class="py-op">)</tt> </tt>
<a name="L79"></a><tt class="py-lineno">79</tt> <tt class="py-line"> <tt class="py-name">mod_or_f</tt><tt class="py-op">,</tt> <tt id="link-14" class="py-name"><a title="logilab.common.configuration.OptionsManagerMixIn.help" class="py-name" href="#" onclick="return doclink('link-14', 'help', 'link-7');">help</a></tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">_commands</tt><tt class="py-op">[</tt><tt class="py-name">cmd</tt><tt class="py-op">]</tt> </tt>
<a name="L80"></a><tt class="py-lineno">80</tt> <tt class="py-line"> <tt class="py-comment"># optparse inserts self.description between usage and options help</tt> </tt>
<a name="L81"></a><tt class="py-lineno">81</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-15" class="py-name" targets="Class Method logilab.common.clcommands.Command.description()=logilab.common.clcommands.Command-class.html#description"><a title="logilab.common.clcommands.Command.description" class="py-name" href="#" onclick="return doclink('link-15', 'description', 'link-15');">description</a></tt> <tt class="py-op">=</tt> <tt id="link-16" class="py-name"><a title="logilab.common.configuration.OptionsManagerMixIn.help" class="py-name" href="#" onclick="return doclink('link-16', 'help', 'link-7');">help</a></tt> </tt>
<a name="L82"></a><tt class="py-lineno">82</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-name">isinstance</tt><tt class="py-op">(</tt><tt class="py-name">mod_or_f</tt><tt class="py-op">,</tt> <tt class="py-name">str</tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L83"></a><tt class="py-lineno">83</tt> <tt class="py-line"> <tt class="py-keyword">exec</tt><tt class="py-op">(</tt><tt class="py-string">'from %s import run, add_options'</tt> <tt class="py-op">%</tt> <tt class="py-name">mod_or_f</tt><tt class="py-op">)</tt> </tt>
<a name="L84"></a><tt class="py-lineno">84</tt> <tt class="py-line"> <tt class="py-keyword">else</tt><tt class="py-op">:</tt> </tt>
<a name="L85"></a><tt class="py-lineno">85</tt> <tt class="py-line"> <tt id="link-17" class="py-name" targets="Method logilab.common.clcommands.Command.run()=logilab.common.clcommands.Command-class.html#run,Method logilab.common.clcommands.CommandLine.run()=logilab.common.clcommands.CommandLine-class.html#run,Method logilab.common.clcommands.ListCommandsCommand.run()=logilab.common.clcommands.ListCommandsCommand-class.html#run,Function logilab.common.sphinx_ext.run()=logilab.common.sphinx_ext-module.html#run"><a title="logilab.common.clcommands.Command.run
logilab.common.clcommands.CommandLine.run
logilab.common.clcommands.ListCommandsCommand.run
logilab.common.sphinx_ext.run" class="py-name" href="#" onclick="return doclink('link-17', 'run', 'link-17');">run</a></tt><tt class="py-op">,</tt> <tt class="py-name">add_options</tt> <tt class="py-op">=</tt> <tt class="py-name">mod_or_f</tt> </tt>
<a name="L86"></a><tt class="py-lineno">86</tt> <tt class="py-line"> <tt class="py-name">add_options</tt><tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">)</tt> </tt>
<a name="L87"></a><tt class="py-lineno">87</tt> <tt class="py-line"> <tt class="py-op">(</tt><tt id="link-18" class="py-name" targets="Variable logilab.common.configuration.OptionsProviderMixIn.options=logilab.common.configuration.OptionsProviderMixIn-class.html#options"><a title="logilab.common.configuration.OptionsProviderMixIn.options" class="py-name" href="#" onclick="return doclink('link-18', 'options', 'link-18');">options</a></tt><tt class="py-op">,</tt> <tt class="py-name">args</tt><tt class="py-op">)</tt> <tt class="py-op">=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt class="py-name">parse_args</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">)</tt> </tt>
<a name="L88"></a><tt class="py-lineno">88</tt> <tt class="py-line"> <tt class="py-keyword">if</tt> <tt class="py-keyword">not</tt> <tt class="py-op">(</tt><tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-19" class="py-name"><a title="logilab.common.clcommands.Command.min_args" class="py-name" href="#" onclick="return doclink('link-19', 'min_args', 'link-4');">min_args</a></tt> <tt class="py-op"><=</tt> <tt class="py-name">len</tt><tt class="py-op">(</tt><tt class="py-name">args</tt><tt class="py-op">)</tt> <tt class="py-op"><=</tt> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-20" class="py-name"><a title="logilab.common.clcommands.Command.max_args" class="py-name" href="#" onclick="return doclink('link-20', 'max_args', 'link-5');">max_args</a></tt><tt class="py-op">)</tt><tt class="py-op">:</tt> </tt>
<a name="L89"></a><tt class="py-lineno">89</tt> <tt class="py-line"> <tt class="py-name">self</tt><tt class="py-op">.</tt><tt id="link-21" class="py-name"><a title="logilab.common.registry.Registry.error
logilab.common.registry.RegistryStore.error" class="py-name" href="#" onclick="return doclink('link-21', 'error', 'link-13');">error</a></tt><tt class="py-op">(</tt><tt class="py-string">'incorrect number of arguments'</tt><tt class="py-op">)</tt> </tt>
<a name="L90"></a><tt class="py-lineno">90</tt> <tt class="py-line"> <tt class="py-keyword">return</tt> <tt id="link-22" class="py-name"><a title="logilab.common.clcommands.Command.run
logilab.common.clcommands.CommandLine.run
logilab.common.clcommands.ListCommandsCommand.run
logilab.common.sphinx_ext.run" class="py-name" href="#" onclick="return doclink('link-22', 'run', 'link-17');">run</a></tt><tt class="py-op">,</tt> <tt id="link-23" class="py-name"><a title="logilab.common.configuration.OptionsProviderMixIn.options" class="py-name" href="#" onclick="return doclink('link-23', 'options', 'link-18');">options</a></tt><tt class="py-op">,</tt> <tt class="py-name">args</tt> </tt>
</div></div><a name="L91"></a><tt class="py-lineno">91</tt> <tt class="py-line"> </tt><script type="text/javascript">
<!--
expandto(location.href);
// -->
</script>
</pre>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th> <a
href="logilab.common-module.html">Home</a> </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
>Logilab's common library</th>
</tr></table></th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1
on Fri Dec 8 00:00:57 2017
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
>http://epydoc.sourceforge.net</a>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
// Private objects are initially displayed (because if
// javascript is turned off then we want them to be
// visible); but by default, we want to hide them. So hide
// them unless we have a cookie that says to show them.
checkCookie();
// -->
</script>
</body>
</html>
|