<?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>flumotion.extern.command.command.CommandOptionParser</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"> <!-- 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> <th class="navbar" width="100%"></th> </tr> </table> <table width="100%" cellpadding="0" cellspacing="0"> <tr valign="top"> <td width="100%"> <span class="breadcrumbs"> Package flumotion :: <a href="flumotion.extern-module.html">Package extern</a> :: <a href="flumotion.extern.command-module.html">Package command</a> :: <a href="flumotion.extern.command.command-module.html">Module command</a> :: Class CommandOptionParser </span> </td> <td> <table cellpadding="0" cellspacing="0"> <!-- hide/show private --> <tr><td align="right"><span class="options">[<a href="javascript:void(0);" class="privatelink" onclick="toggle_private();">hide private</a>]</span></td></tr> </table> </td> </tr> </table> <!-- ==================== CLASS DESCRIPTION ==================== --> <h1 class="epydoc">Class CommandOptionParser</h1><p class="nomargin-top"><span class="codelink"><a href="flumotion.extern.command.command-pysrc.html#CommandOptionParser">source code</a></span></p> <pre class="base-tree"> optparse.OptionContainer --+ | optparse.OptionParser --+ | <strong class="uidshort">CommandOptionParser</strong> </pre> <hr /> <p>I parse options as usual, but I explicitly allow setting stdout so that our print_help() method (invoked by default with -h/--help) defaults to writing there.</p> <p>I also override exit() so that I can be used in interactive shells.</p> <!-- ==================== INSTANCE METHODS ==================== --> <a name="section-InstanceMethods"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Instance Methods</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-InstanceMethods" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a name="set_stdout"></a><span class="summary-sig-name">set_stdout</span>(<span class="summary-sig-arg">self</span>, <span class="summary-sig-arg">stdout</span>)</span></td> <td align="right" valign="top"> <span class="codelink"><a href="flumotion.extern.command.command-pysrc.html#CommandOptionParser.set_stdout">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="flumotion.extern.command.command.CommandOptionParser-class.html#parse_args" class="summary-sig-name">parse_args</a>(<span class="summary-sig-arg">self</span>, <span class="summary-sig-arg">args</span>=<span class="summary-sig-default">None</span>, <span class="summary-sig-arg">values</span>=<span class="summary-sig-default">None</span>)</span><br /> parse_args(args : [string] = sys.argv[1:], values : Values = None) -> (values : Values, args : [string])</td> <td align="right" valign="top"> <span class="codelink"><a href="flumotion.extern.command.command-pysrc.html#CommandOptionParser.parse_args">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="flumotion.extern.command.command.CommandOptionParser-class.html#print_help" class="summary-sig-name">print_help</a>(<span class="summary-sig-arg">self</span>, <span class="summary-sig-arg">file</span>=<span class="summary-sig-default">None</span>)</span><br /> print_help(file : file = stdout)</td> <td align="right" valign="top"> <span class="codelink"><a href="flumotion.extern.command.command-pysrc.html#CommandOptionParser.print_help">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="flumotion.extern.command.command.CommandOptionParser-class.html#print_usage" class="summary-sig-name">print_usage</a>(<span class="summary-sig-arg">self</span>, <span class="summary-sig-arg">file</span>=<span class="summary-sig-default">None</span>)</span><br /> print_usage(file : file = stdout)</td> <td align="right" valign="top"> <span class="codelink"><a href="flumotion.extern.command.command-pysrc.html#CommandOptionParser.print_usage">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr> <td><span class="summary-sig"><a href="flumotion.extern.command.command.CommandOptionParser-class.html#exit" class="summary-sig-name">exit</a>(<span class="summary-sig-arg">self</span>, <span class="summary-sig-arg">status</span>=<span class="summary-sig-default">0</span>, <span class="summary-sig-arg">msg</span>=<span class="summary-sig-default">None</span>)</span></td> <td align="right" valign="top"> <span class="codelink"><a href="flumotion.extern.command.command-pysrc.html#CommandOptionParser.exit">source code</a></span> </td> </tr> </table> </td> </tr> <tr> <td colspan="2" class="summary"> <p class="indent-wrapped-lines"><b>Inherited from <code>optparse.OptionParser</code></b>: <code>__init__</code>, <code>add_option_group</code>, <code>check_values</code>, <code>destroy</code>, <code>disable_interspersed_args</code>, <code>enable_interspersed_args</code>, <code>error</code>, <code>expand_prog_name</code>, <code>format_epilog</code>, <code>format_help</code>, <code>format_option_help</code>, <code>get_default_values</code>, <code>get_description</code>, <code>get_option_group</code>, <code>get_prog_name</code>, <code>get_usage</code>, <code>get_version</code>, <code>print_version</code>, <code>set_default</code>, <code>set_defaults</code>, <code>set_process_default_values</code>, <code>set_usage</code> </p> <div class="private"> <p class="indent-wrapped-lines"><b>Inherited from <code>optparse.OptionParser</code></b> (private): <code>_add_help_option</code>, <code>_add_version_option</code>, <code>_create_option_list</code>, <code>_get_all_options</code>, <code>_get_args</code>, <code>_get_encoding</code>, <code>_init_parsing_state</code>, <code>_match_long_opt</code>, <code>_populate_option_list</code>, <code>_process_args</code>, <code>_process_long_opt</code>, <code>_process_short_opts</code> </p></div> <p class="indent-wrapped-lines"><b>Inherited from <code>optparse.OptionContainer</code></b>: <code>add_option</code>, <code>add_options</code>, <code>format_description</code>, <code>get_option</code>, <code>has_option</code>, <code>remove_option</code>, <code>set_conflict_handler</code>, <code>set_description</code> </p> <div class="private"> <p class="indent-wrapped-lines"><b>Inherited from <code>optparse.OptionContainer</code></b> (private): <code>_check_conflict</code>, <code>_create_option_mappings</code>, <code>_share_option_mappings</code> </p></div> </td> </tr> </table> <!-- ==================== CLASS VARIABLES ==================== --> <a name="section-ClassVariables"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Class Variables</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-ClassVariables" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> <tr class="private"> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="_stdout"></a><span class="summary-name">_stdout</span> = <code title="sys.stdout">sys.stdout</code> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="__pychecker__"></a><span class="summary-name">__pychecker__</span> = <code title="'no-shadowbuiltin'"><code class="variable-quote">'</code><code class="variable-string">no-shadowbuiltin</code><code class="variable-quote">'</code></code> </td> </tr> <tr> <td colspan="2" class="summary"> <p class="indent-wrapped-lines"><b>Inherited from <code>optparse.OptionParser</code></b>: <code>standard_option_list</code> </p> </td> </tr> </table> <!-- ==================== INSTANCE VARIABLES ==================== --> <a name="section-InstanceVariables"></a> <table class="summary" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Instance Variables</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-InstanceVariables" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="help_printed"></a><span class="summary-name">help_printed</span> = <code title="False">False</code><br /> whether help was printed during parsing </td> </tr> <tr> <td width="15%" align="right" valign="top" class="summary"> <span class="summary-type"> </span> </td><td class="summary"> <a name="usage_printed"></a><span class="summary-name">usage_printed</span> = <code title="False">False</code><br /> whether usage was printed during parsing </td> </tr> </table> <!-- ==================== METHOD DETAILS ==================== --> <a name="section-MethodDetails"></a> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr bgcolor="#70b0f0" class="table-header"> <td colspan="2" class="table-header"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr valign="top"> <td align="left"><span class="table-header">Method Details</span></td> <td align="right" valign="top" ><span class="options">[<a href="#section-MethodDetails" class="privatelink" onclick="toggle_private();" >hide private</a>]</span></td> </tr> </table> </td> </tr> </table> <a name="parse_args"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">parse_args</span>(<span class="sig-arg">self</span>, <span class="sig-arg">args</span>=<span class="sig-default">None</span>, <span class="sig-arg">values</span>=<span class="sig-default">None</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="flumotion.extern.command.command-pysrc.html#CommandOptionParser.parse_args">source code</a></span> </td> </tr></table> <pre class="literalblock"> parse_args(args : [string] = sys.argv[1:], values : Values = None) -> (values : Values, args : [string]) Parse the command-line options found in 'args' (default: sys.argv[1:]). Any errors result in a call to 'error()', which by default prints the usage message to stderr and calls sys.exit() with an error message. On success returns a pair (values, args) where 'values' is an Values instance (with all your option values) and 'args' is the list of arguments left over after parsing options. </pre> <dl class="fields"> <dt>Overrides: optparse.OptionParser.parse_args <dd><em class="note">(inherited documentation)</em></dd> </dt> </dl> </td></tr></table> </div> <a name="print_help"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">print_help</span>(<span class="sig-arg">self</span>, <span class="sig-arg">file</span>=<span class="sig-default">None</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="flumotion.extern.command.command-pysrc.html#CommandOptionParser.print_help">source code</a></span> </td> </tr></table> <p>print_help(file : file = stdout)</p> <p>Print an extended help message, listing all options and any help text provided with them, to 'file' (default stdout).</p> <dl class="fields"> <dt>Overrides: optparse.OptionParser.print_help <dd><em class="note">(inherited documentation)</em></dd> </dt> </dl> </td></tr></table> </div> <a name="print_usage"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">print_usage</span>(<span class="sig-arg">self</span>, <span class="sig-arg">file</span>=<span class="sig-default">None</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="flumotion.extern.command.command-pysrc.html#CommandOptionParser.print_usage">source code</a></span> </td> </tr></table> <p>print_usage(file : file = stdout)</p> <p>Print the usage message for the current program (self.usage) to 'file' (default stdout). Any occurrence of the string "%prog" in self.usage is replaced with the name of the current program (basename of sys.argv[0]). Does nothing if self.usage is empty or not defined.</p> <dl class="fields"> <dt>Overrides: optparse.OptionParser.print_usage <dd><em class="note">(inherited documentation)</em></dd> </dt> </dl> </td></tr></table> </div> <a name="exit"></a> <div> <table class="details" border="1" cellpadding="3" cellspacing="0" width="100%" bgcolor="white"> <tr><td> <table width="100%" cellpadding="0" cellspacing="0" border="0"> <tr valign="top"><td> <h3 class="epydoc"><span class="sig"><span class="sig-name">exit</span>(<span class="sig-arg">self</span>, <span class="sig-arg">status</span>=<span class="sig-default">0</span>, <span class="sig-arg">msg</span>=<span class="sig-default">None</span>)</span> </h3> </td><td align="right" valign="top" ><span class="codelink"><a href="flumotion.extern.command.command-pysrc.html#CommandOptionParser.exit">source code</a></span> </td> </tr></table> <dl class="fields"> <dt>Overrides: optparse.OptionParser.exit </dt> </dl> </td></tr></table> </div> <br /> <!-- ==================== NAVIGATION BAR ==================== --> <table class="navbar" border="0" width="100%" cellpadding="0" bgcolor="#a0c0ff" cellspacing="0"> <tr valign="middle"> <!-- 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> <th class="navbar" width="100%"></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 Wed Aug 11 21:33:16 2010 </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>