�`^c@s�dZdZdddddddd d
ddd
ddddgZdZddlZddlZddlZddlZd�Zyddl m Z Wne
k
r�d�Z nXe Zd
efd��YZ
de
fd��YZdefd��YZde
fd��YZde
fd��YZdefd��YZd
fd��YZdefd ��YZdefd!��YZd"�Zd#�Zd$�Zieed%�fd&6eed'�fd(6eed)�fd*6eed+�fd+6Zd,�Zd-�Zd.d/fZdfd0��YZd1d2Z d1d3Z!ye"Wne#k
rQd4�Z$n
Xd5�Z$dfd6��YZ%dfd7��YZ&de&fd8��YZ'd e&fd9��YZ(d:�Z)eZ*dS(;s�A powerful, extensible, and easy-to-use option parser.
By Greg Ward <gward@python.net>
Originally distributed as Optik.
For support, use the optik-users@lists.sourceforge.net mailing list
(http://lists.sourceforge.net/lists/listinfo/optik-users).
Simple usage example:
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
help="write report to FILE", metavar="FILE")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose", default=True,
help="don't print status messages to stdout")
(options, args) = parser.parse_args()
s1.5.3tOptiontmake_optiont
SUPPRESS_HELPtSUPPRESS_USAGEtValuestOptionContainertOptionGrouptOptionParsert
HelpFormattertIndentedHelpFormattertTitledHelpFormattert
OptParseErrortOptionErrortOptionConflictErrortOptionValueErrortBadOptionErrors"
Copyright (c) 2001-2006 Gregory P. Ward. All rights reserved.
Copyright (c) 2002-2006 Python Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the author nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
i�NcCsd|jjt|�|fS(Ns<%s at 0x%x: %s>(t __class__t__name__tid(tself((s/sys/lib/python2.7/optparse.pyt_reprOs(tgettextcCs|S(N((tmessage((s/sys/lib/python2.7/optparse.pyR\scBseZd�Zd�ZRS(cCs
||_dS(N(tmsg(RR((s/sys/lib/python2.7/optparse.pyt__init__bscCs|jS(N(R(R((s/sys/lib/python2.7/optparse.pyt__str__es(Rt
__module__RR(((s/sys/lib/python2.7/optparse.pyRas cBs eZdZd�Zd�ZRS(s]
Raised if an Option instance is created with invalid or
inconsistent arguments.
cCs||_t|�|_dS(N(Rtstrt option_id(RRtoption((s/sys/lib/python2.7/optparse.pyRos cCs(|jrd|j|jfS|jSdS(Ns
option %s: %s(RR(R((s/sys/lib/python2.7/optparse.pyRss (RRt__doc__RR(((s/sys/lib/python2.7/optparse.pyRis cBseZdZRS(sE
Raised if conflicting options are added to an OptionParser.
(RRR(((s/sys/lib/python2.7/optparse.pyR
yscBseZdZRS(sS
Raised if an invalid option value is encountered on the command
line.
(RRR(((s/sys/lib/python2.7/optparse.pyR~scBs eZdZd�Zd�ZRS(sB
Raised if an invalid option is seen on the command line.
cCs
||_dS(N(topt_str(RR((s/sys/lib/python2.7/optparse.pyR�scCstd�|jS(Nsno such option: %s(t_R(R((s/sys/lib/python2.7/optparse.pyR�s(RRRRR(((s/sys/lib/python2.7/optparse.pyR�s tAmbiguousOptionErrorcBs eZdZd�Zd�ZRS(sD
Raised if an ambiguous option is seen on the command line.
cCstj||�||_dS(N(RRt
possibilities(RRR"((s/sys/lib/python2.7/optparse.pyR�scCs#td�|jdj|j�fS(Nsambiguous option: %s (%s?)s, (R RtjoinR"(R((s/sys/lib/python2.7/optparse.pyR�s (RRRRR(((s/sys/lib/python2.7/optparse.pyR!�s cBs�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d �Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�ZRS(s�
Abstract base class for formatting option help. OptionParser
instances should use one of the HelpFormatter subclasses for
formatting help; by default IndentedHelpFormatter is used.
Instance attributes:
parser : OptionParser
the controlling OptionParser instance
indent_increment : int
the number of columns to indent per nesting level
max_help_position : int
the maximum starting column for option help text
help_position : int
the calculated starting column for option help text;
initially the same as the maximum
width : int
total number of columns for output (pass None to constructor for
this value to be taken from the $COLUMNS environment variable)
level : int
current indentation level
current_indent : int
current indentation level (in columns)
help_width : int
number of columns available for option help text (calculated)
default_tag : str
text to replace with each option's default value, "%default"
by default. Set to false value to disable default value expansion.
option_strings : { Option : str }
maps Option instances to the snippet of help text explaining
the syntax of that option, e.g. "-h, --help" or
"-fFILE, --file=FILE"
_short_opt_fmt : str
format string controlling how short options with values are
printed in help text. Must be either "%s%s" ("-fFILE") or
"%s %s" ("-f FILE"), because those are the two syntaxes that
Optik supports.
_long_opt_fmt : str
similar but for long options; must be either "%s %s" ("--file FILE")
or "%s=%s" ("--file=FILE").
tnonecCs�d|_||_|dkrbyttjd�}Wnttfk
rTd}nX|d8}n||_t |t
|d|d��|_|_d|_
d|_d|_||_d|_i|_d|_d|_dS( NtCOLUMNSiPiiis%defaults%s %ss%s=%s(tNonetparsertindent_incrementtinttostenvirontKeyErrort
ValueErrortwidthtmintmaxt
help_positiontmax_help_positiontcurrent_indenttlevelt
help_widthtshort_firsttdefault_tagtoption_stringst_short_opt_fmtt
_long_opt_fmt(RR(R2R.R6((s/sys/lib/python2.7/optparse.pyR�s$
* cCs
||_dS(N(R'(RR'((s/sys/lib/python2.7/optparse.pyt
set_parser�scCs4|dkrtd|��nd|d|_dS(Ntt s/invalid metavar delimiter for short options: %rs%s(R<R=(R-R9(Rtdelim((s/sys/lib/python2.7/optparse.pytset_short_opt_delimiter�scCs4|dkrtd|��nd|d|_dS(Nt=R=s.invalid metavar delimiter for long options: %rs%s(R@R=(R-R:(RR>((s/sys/lib/python2.7/optparse.pytset_long_opt_delimiter�scCs%|j|j7_|jd7_dS(Ni(R3R(R4(R((s/sys/lib/python2.7/optparse.pytindent�scCs%|j|j8_|jd8_dS(Ni(R3R(R4(R((s/sys/lib/python2.7/optparse.pytdedent�scCs
td�dS(Nssubclasses must implement(tNotImplementedError(Rtusage((s/sys/lib/python2.7/optparse.pytformat_usage�scCs
td�dS(Nssubclasses must implement(RD(Rtheading((s/sys/lib/python2.7/optparse.pytformat_heading�scCsBt|j|jd�}d|j}tj||d|d|�S(s�
Format a paragraph of free-form text for inclusion in the
help output at the current indentation level.
iR=tinitial_indenttsubsequent_indent(R0R.R3ttextwraptfill(Rttextt
text_widthRB((s/sys/lib/python2.7/optparse.pyt_format_text�s
cCs|r|j|�dSdSdS(Ns
R<(RO(Rtdescription((s/sys/lib/python2.7/optparse.pytformat_descriptionscCs#|rd|j|�dSdSdS(Ns
R<(RO(Rtepilog((s/sys/lib/python2.7/optparse.pyt
format_epilogscCsx|jdks|jr |jS|jjj|j�}|tksP|dkr\|j}n|jj |jt
|��S(N(R'R&R7thelptdefaultstgettdestt
NO_DEFAULTtNO_DEFAULT_VALUEtreplaceR(RRt
default_value((s/sys/lib/python2.7/optparse.pytexpand_defaultsc Cs6g}|j|}|j|jd}t|�|kr[d|jd|f}|j}nd|jd||f}d}|j|�|jr |j|�}tj||j �}|jd|d|df�|j
g|dD]}d|jd|f^q�n |ddkr)|jd�ndj|�S( Nis%*s%s
R<s %*s%-*s iii�s
(R8R1R3tlentappendRTR\RKtwrapR5textendR#( RRtresulttoptst opt_widthtindent_firstt help_textt
help_linestline((s/sys/lib/python2.7/optparse.pyt
format_option"s$
.cCs|j�d}xI|jD]>}|j|�}||j|<t|t|�|j�}qW|j�x]|jD]R}xI|jD]>}|j|�}||j|<t|t|�|j�}q�WqpW|j�|j�t |d|j
�|_t|j|jd�|_
dS(Niii(RBtoption_listtformat_option_stringsR8R0R]R3t
option_groupsRCR/R2R1R.R5(RR'tmax_lentopttstringstgroup((s/sys/lib/python2.7/optparse.pytstore_option_stringsEs
$
cCs�|j�ry|jp!|jj�}g|jD]}|j||f^q.}g|jD]}|j||f^qW}n|j}|j}|jr�||}n
||}dj |�S(s@Return a comma-separated list of option strings & metavariables.s, (
ttakes_valuetmetavarRWtuppert_short_optsR9t
_long_optsR:R6R#(RRRrtsoptt
short_optstloptt long_optsRb((s/sys/lib/python2.7/optparse.pyRjWs&)
(RRRRYRR;R?RARBRCRFRHRORQRSR\RhRpRj(((s/sys/lib/python2.7/optparse.pyR�s")
# cBs5eZdZddddd�Zd�Zd�ZRS(s.Format help with indented section bodies.
iiicCstj|||||�dS(N(RR(RR(R2R.R6((s/sys/lib/python2.7/optparse.pyRnscCstd�|S(Ns
Usage: %s
(R (RRE((s/sys/lib/python2.7/optparse.pyRFvscCsd|jd|fS(Ns%*s%s:
R<(R3(RRG((s/sys/lib/python2.7/optparse.pyRHysN(RRRR&RRFRH(((s/sys/lib/python2.7/optparse.pyR js cBs5eZdZddddd�Zd�Zd�ZRS(s1Format help with underlined section headers.
iicCstj|||||�dS(N(RR(RR(R2R.R6((s/sys/lib/python2.7/optparse.pyR�scCsd|jtd��|fS(Ns%s %s
tUsage(RHR (RRE((s/sys/lib/python2.7/optparse.pyRF�scCsd|d|jt|�fS(Ns%s
%s
s=-(R4R](RRG((s/sys/lib/python2.7/optparse.pyRH�sN(RRRR&RRFRH(((s/sys/lib/python2.7/optparse.pyR
}s cCsz|d j�dkrd}nN|d j�dkrNd}|dpHd}n|d dkrgd}nd}|||�S( Nit0xit0bt0iii
(tlower(tvalttypetradix((s/sys/lib/python2.7/optparse.pyt
_parse_num�s cCs
t|t�S(N(R�R)(R((s/sys/lib/python2.7/optparse.pyt
_parse_int�scCs
t|t�S(N(R�tlong(R((s/sys/lib/python2.7/optparse.pyt_parse_long�stintegerR)slong integerR�sfloating-pointtfloattcomplexcCsXt|j\}}y||�SWn0tk
rSttd�|||f��nXdS(Nsoption %s: invalid %s value: %r(t_builtin_cvtR�R-RR (RRmtvaluetcvttwhat((s/sys/lib/python2.7/optparse.pyt
check_builtin�s
cCsQ||jkr|Sdjtt|j��}ttd�|||f��dS(Ns, s.option %s: invalid choice: %r (choose from %s)(tchoicesR#tmaptreprRR (RRmR�R�((s/sys/lib/python2.7/optparse.pytcheck_choice�s tNOtDEFAULTcBsNeZdZddddddddd d
ddgZd-Zd.Zd/Zd0Zd1Zd2Z ie
d6e
d6e
d6e
d6ed6Zd3Zd�Zd�Zd�Zd�Zd�Zd �Zd!�Zd"�Zd#�Zd$�Zd%�ZeeeeeeegZd&�ZeZd'�Zd(�Zd)�Zd*�Z d+�Z!d,�Z"RS(4sr
Instance attributes:
_short_opts : [string]
_long_opts : [string]
action : string
type : string
dest : string
default : any
nargs : int
const : any
choices : [string]
callback : function
callback_args : (any*)
callback_kwargs : { string : any }
help : string
metavar : string
tactionR�RWtdefaulttnargstconstR�tcallbackt
callback_argstcallback_kwargsRTRrtstoretstore_constt
store_truetstore_falseR^tappend_consttcounttversiontstringR)R�R�R�tchoicecOs]g|_g|_|j|�}|j|�|j|�x|jD]}||�qEWdS(N(RtRut_check_opt_stringst_set_opt_stringst
_set_attrst
CHECK_METHODS(RRbtattrstchecker((s/sys/lib/python2.7/optparse.pyR1s
cCs(td|�}|s$td��n|S(Ns+at least one option string must be supplied(tfilterR&t TypeError(RRb((s/sys/lib/python2.7/optparse.pyR�DscCs�x�|D]�}t|�dkr5td||��qt|�dkr�|ddkod|ddks}td||��n|jj|�q|dd!dko�|ddks�td||��n|jj|�qWdS( Nis>invalid option string %r: must be at least two characters longit-isMinvalid short option string %r: must be of the form -x, (x any non-dash char)s--sGinvalid long option string %r: must start with --, followed by non-dash(R]RRtR^Ru(RRbRm((s/sys/lib/python2.7/optparse.pyR�Ms$
#cCs�xj|jD]_}||kr:t||||�||=q
|dkrYt||t�q
t||d�q
W|r�|j�}|j�tddj|�|��ndS(NR�sinvalid keyword arguments: %ss, (tATTRStsetattrRXR&tkeystsortRR#(RR�tattr((s/sys/lib/python2.7/optparse.pyR�bs
cCsJ|jdkrd|_n+|j|jkrFtd|j|��ndS(NR�sinvalid action: %r(R�R&tACTIONSR(R((s/sys/lib/python2.7/optparse.pyt
_check_actionvscCs)|jdkrK|j|jkr%|jdk r<d|_qHd|_q%n�ddl}t|j�tjks�t|jd�r�t ||jj
d�|jkr�|jj
|_n|jdkr�d|_n|j|jkr�d|j|��n|j|j
kr%td|j|��ndS(NR�R�i�RRsinvalid option type: %rs$must not supply a type for action %r(R�R&R�tALWAYS_TYPED_ACTIONSR�t__builtin__ttypestTypeTypethasattrtgetattrRtTYPESRt
TYPED_ACTIONS(RR�((s/sys/lib/python2.7/optparse.pyt_check_type|s"!cCs�|jdkr�|jdkr0td|��q�t|j�tjtjfkr�tdtt|j��jd�d|��q�n(|jdk r�td|j|��ndS(NR�s/must supply a list of choices for type 'choice's1choices must be a list of strings ('%s' supplied)t'is#must not supply choices for type %r( R�R�R&RR�t TupleTypetListTypeRtsplit(R((s/sys/lib/python2.7/optparse.pyt
_check_choice�s!/cCs}|j|jkp|jdk }|jdkry|ry|jrb|jddjdd�|_qy|jdd|_ndS(NiiR�R i(R�t
STORE_ACTIONSR�R&RWRuRZRt(RRq((s/sys/lib/python2.7/optparse.pyt_check_dest�s #cCs>|j|jkr:|jdk r:td|j|��ndS(Ns*'const' must not be supplied for action %r(R�t
CONST_ACTIONSR�R&R(R((s/sys/lib/python2.7/optparse.pyt_check_const�s!
cCs\|j|jkr0|jdkrXd|_qXn(|jdk rXtd|j|��ndS(Nis*'nargs' must not be supplied for action %r(R�R�R�R&R(R((s/sys/lib/python2.7/optparse.pyt_check_nargs�s
cCs+|jdkr�t|jd�s:td|j|��n|jdk rzt|j�tjk rztd|j|��n|j dk r't|j �tj
k r'td|j |��q'nj|jdk r�d|j|��n|jdk rtd|��n|j dk r'td|��ndS( NR�t__call__scallback not callable: %rs3callback_args, if supplied, must be a tuple: not %rs4callback_kwargs, if supplied, must be a dict: not %rs.callback supplied (%r) for non-callback options.callback_args supplied for non-callback options0callback_kwargs supplied for non-callback option(R�R�R�RR�R&R�R�R�R�tDictType(R((s/sys/lib/python2.7/optparse.pyt_check_callback�s0cCsdj|j|j�S(Nt/(R#RtRu(R((s/sys/lib/python2.7/optparse.pyR�scCs
|jdk S(N(R�R&(R((s/sys/lib/python2.7/optparse.pyRq�scCs#|jr|jdS|jdSdS(Ni(RuRt(R((s/sys/lib/python2.7/optparse.pytget_opt_string�s cCs9|jj|j�}|dkr%|S||||�SdS(N(tTYPE_CHECKERRVR�R&(RRmR�R�((s/sys/lib/python2.7/optparse.pytcheck_value�scCs[|dk rW|jdkr+|j||�Stg|D]}|j||�^q5�SndS(Ni(R&R�R�ttuple(RRmR�tv((s/sys/lib/python2.7/optparse.pyt
convert_valuescCs4|j||�}|j|j|j||||�S(N(R�ttake_actionR�RW(RRmR�tvaluesR'((s/sys/lib/python2.7/optparse.pytprocesssc Cs�|dkrt|||�n�|dkrAt|||j�nb|dkr`t||t�nC|dkrt||t�n$|dkr�|j|g�j|�n�dkr�|j|g�j|j�n�|dkrt|||j|d�d �n�|d
krJ|jpd}|jp(i}|j||||||�nY|dkrm|j �|j
�n6|dkr�|j�|j
�ntd
|j
��d S(NR�R�R�R�R^R�R�iiR�RTR�sunknown action %r((R�R�tTruetFalsetensure_valueR^R�R�R�t
print_helptexitt
print_versionR-R�( RR�RWRmR�R�R'targstkwargs((s/sys/lib/python2.7/optparse.pyR�s4#
(
sstoresstore_consts
store_truesstore_falsesappendsappend_constscountscallbackshelpsversion(sstoresstore_consts
store_truesstore_falsesappendsappend_constscount(sstoresappendscallback(sstoresappend(sstore_constsappend_const(sstringsintslongsfloatscomplexschoiceN(#RRRR�R�R�R�R�R�R�R�R�R�R&R�RR�R�R�R�R�R�R�R�R�R�RRt__repr__RqR�R�R�R�R�(((s/sys/lib/python2.7/optparse.pyR�s�
tSUPPRESStHELPtUSAGEcCst|tjtjf�S(N(t
isinstanceR�t
StringTypetUnicodeType(tx((s/sys/lib/python2.7/optparse.pytisbasestring>scCs
t|t�S(N(R�t
basestring(R�((s/sys/lib/python2.7/optparse.pyR�AscBsheZd
d�Zd�ZeZd�Zd�Zd�Z d�Z
dd�Zdd�Zd �Z
RS(cCs:|r6x-|j�D]\}}t|||�qWndS(N(titemsR�(RRUR�R((s/sys/lib/python2.7/optparse.pyRFscCs
t|j�S(N(Rt__dict__(R((s/sys/lib/python2.7/optparse.pyRKscCsLt|t�r"t|j|j�St|tj�rDt|j|�SdSdS(Ni�(R�RtcmpR�R�R�(Rtother((s/sys/lib/python2.7/optparse.pyt__cmp__Ps
cCsSxLt|�D]>}||kr
||}|dk rKt|||�qKq
q
WdS(s�
Update the option values from an arbitrary dictionary, but only
use keys from dict that already have a corresponding attribute
in self. Any keys in dict without a corresponding attribute
are silently ignored.
N(tdirR&R�(RtdictR�tdval((s/sys/lib/python2.7/optparse.pyt_update_carefulXs
cCs|jj|�dS(s�
Update the option values from an arbitrary dictionary,
using all keys from the dictionary regardless of whether
they have a corresponding attribute in self or not.
N(R�tupdate(RR�((s/sys/lib/python2.7/optparse.pyt
_update_looseescCsI|dkr|j|�n)|dkr8|j|�n
td|�dS(Ntcarefultloosesinvalid update mode: %r(R�R�R-(RR�tmode((s/sys/lib/python2.7/optparse.pyt_updatems
R�cCs1t|�tj|}|jt|�|�dS(N(t
__import__tsystmodulesR�tvars(RtmodnameR�tmod((s/sys/lib/python2.7/optparse.pytread_moduleus
cCs'i}t||�|j||�dS(N(texecfileR�(RtfilenameR�R�((s/sys/lib/python2.7/optparse.pyt read_filezs
cCsEt||�s%t||�dkr8t|||�nt||�S(N(R�R�R&R�(RR�R�((s/sys/lib/python2.7/optparse.pyR�s%N(RRR&RRRR�R�R�R�R�R�R�R�(((s/sys/lib/python2.7/optparse.pyRDs
cBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d �Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�ZRS(s�
Abstract base class.
Class attributes:
standard_option_list : [Option]
list of standard options that will be accepted by all instances
of this parser class (intended to be overridden by subclasses).
Instance attributes:
option_list : [Option]
the list of Option objects contained by this OptionContainer
_short_opt : { string : Option }
dictionary mapping short option strings, eg. "-f" or "-X",
to the Option instances that implement them. If an Option
has multiple short option strings, it will appears in this
dictionary multiple times. [1]
_long_opt : { string : Option }
dictionary mapping long option strings, eg. "--file" or
"--exclude", to the Option instances that implement them.
Again, a given Option can occur multiple times in this
dictionary. [1]
defaults : { string : any }
dictionary mapping option destination names to default
values for each destination [1]
[1] These mappings are common to (shared by) all components of the
controlling OptionParser, where they are initially created.
cCs1|j�||_|j|�|j|�dS(N(t_create_option_listtoption_classtset_conflict_handlertset_description(RRtconflict_handlerRP((s/sys/lib/python2.7/optparse.pyR�s
cCsi|_i|_i|_dS(N(t
_short_optt _long_optRU(R((s/sys/lib/python2.7/optparse.pyt_create_option_mappings�s cCs(|j|_|j|_|j|_dS(N(RRRU(RR'((s/sys/lib/python2.7/optparse.pyt_share_option_mappings�scCs)|dkrtd|�n||_dS(Nterrortresolves$invalid conflict_resolution value %r(serrorR (R-R(Rthandler((s/sys/lib/python2.7/optparse.pyR�scCs
||_dS(N(RP(RRP((s/sys/lib/python2.7/optparse.pyR�scCs|jS(N(RP(R((s/sys/lib/python2.7/optparse.pytget_description�scCs|`|`|`dS(ssee OptionParser.destroy().N(RRRU(R((s/sys/lib/python2.7/optparse.pytdestroy�scCsrg}x=|jD]2}||jkr|j||j|f�qqWx=|jD]2}||jkrP|j||j|f�qPqPW|rn|j}|dkr�tddjg|D]}|d^q��|��qn|dkrnx�|D]z\}}|jd�r"|jj |�|j|=n|jj |�|j|=|jpK|js�j
jj |�q��qnndS(NRs conflicting option string(s): %ss, iR s--(RtRR^RuRRR
R#t
startswithtremovet containerRi(RRt
conflict_optsRmR
tcotc_option((s/sys/lib/python2.7/optparse.pyt_check_conflict�s.!! $
cOsDt|d�tjkr.|j||�}nNt|�dkrs|rs|d}t|t�s|td|�q|n td�|j|�|j j
|�||_x|jD]}||j
|<q�Wx|jD]}||j|<q�W|jdk r@|jtk r|j|j|j<q@|j|jkr@d|j|j<q@n|S(sOadd_option(Option)
add_option(opt_str, ..., kwarg=val, ...)
iisnot an Option instance: %rsinvalid argumentsN(R�R�tStringTypesRR]R�RR�RRiR^RRtRRuRRWR&R�RXRU(RR�R�RRm((s/sys/lib/python2.7/optparse.pyt
add_option�s(
cCs"x|D]}|j|�qWdS(N(R(RRiR((s/sys/lib/python2.7/optparse.pytadd_optionss
cCs"|jj|�p!|jj|�S(N(RRVR(RR((s/sys/lib/python2.7/optparse.pyt
get_optionscCs||jkp||jkS(N(RR(RR((s/sys/lib/python2.7/optparse.pyt
has_optionscCs�|jj|�}|dkr3|jj|�}n|dkrRtd|��nx|jD]}|j|=q\Wx|jD]}|j|=qzW|jjj |�dS(Nsno such option %r(
RRVR&RR-RtRuRRiR(RRRRm((s/sys/lib/python2.7/optparse.pyt
remove_optionscCs\|js
dSg}x9|jD].}|jtk r|j|j|��qqWdj|�S(NR<(RiRTRR^RhR#(Rt formatterRaR((s/sys/lib/python2.7/optparse.pytformat_option_help,s cCs|j|j��S(N(RQR(RR((s/sys/lib/python2.7/optparse.pyRQ5scCsWg}|jr(|j|j|��n|jrJ|j|j|��ndj|�S(Ns
(RPR^RQRiRR#(RRRa((s/sys/lib/python2.7/optparse.pytformat_help8s (RRRRRRRRRRRRRRRRRRQR(((s/sys/lib/python2.7/optparse.pyR�s" cBs8eZdd�Zd�Zd�Zd�Zd�ZRS(cCs2||_tj||j|j|�||_dS(N(R'RRRRttitle(RR'RRP((s/sys/lib/python2.7/optparse.pyRCs cCsg|_|j|j�dS(N(RiRR'(R((s/sys/lib/python2.7/optparse.pyR�Is cCs
||_dS(N(R(RR((s/sys/lib/python2.7/optparse.pyt set_titleMscCstj|�|`dS(ssee OptionParser.destroy().N(RRRi(R((s/sys/lib/python2.7/optparse.pyRPs
cCs@|j|j�}|j�|tj||�7}|j�|S(N(RHRRBRRRC(RRRa((s/sys/lib/python2.7/optparse.pyRWs
N(RRR&RR�RRR(((s/sys/lib/python2.7/optparse.pyRAs
cBs�eZdZgZd)d)ed)dd)d)ed)d)d�Zd�Zd�Z d�Z
d�Zed�Zd�Z
d �Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd)d)d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!dd)d�Z"d�Z#d �Z$d)d!�Z%d"�Z&d)d#�Z'd)d$�Z(d%�Z)d)d&�Z*d'�Z+d)d(�Z,RS(*s$
Class attributes:
standard_option_list : [Option]
list of standard options that will be accepted by all instances
of this parser class (intended to be overridden by subclasses).
Instance attributes:
usage : string
a usage string for your program. Before it is displayed
to the user, "%prog" will be expanded to the name of
your program (self.prog or os.path.basename(sys.argv[0])).
prog : string
the name of the current program (to override
os.path.basename(sys.argv[0])).
description : string
A paragraph of text giving a brief overview of your program.
optparse reformats this paragraph to fit the current terminal
width and prints it when the user requests help (after usage,
but before the list of options).
epilog : string
paragraph of help text to print after option help
option_groups : [OptionGroup]
list of option groups in this parser (option groups are
irrelevant for parsing the command-line, but very useful
for generating help)
allow_interspersed_args : bool = true
if true, positional arguments may be interspersed with options.
Assuming -a and -b each take a single argument, the command-line
-ablah foo bar -bboo baz
will be interpreted the same as
-ablah -bboo -- foo bar baz
If this flag were false, that command line would be interpreted as
-ablah -- foo bar -bboo baz
-- ie. we stop processing options as soon as we see the first
non-option argument. (This is the tradition followed by
Python's getopt module, Perl's Getopt::Std, and other argument-
parsing libraries, but it is generally annoying to users.)
process_default_values : bool = true
if true, option default values are processed similarly to option
values from the command line: that is, they are passed to the
type-checking function for the option's type (as long as the
default value is a string). (This really only matters if you
have defined custom types; see SF bug #955889.) Set it to false
to restore the behaviour of Optik 1.4.1 and earlier.
rargs : [string]
the argument list currently being parsed. Only set when
parse_args() is active, and continually trimmed down as
we consume arguments. Mainly there for the benefit of
callback options.
largs : [string]
the list of leftover arguments that we have skipped while
parsing options. If allow_interspersed_args is false, this
list is always empty.
values : Values
the set of option values currently being accumulated. Only
set when parse_args() is active. Also mainly for callbacks.
Because of the 'rargs', 'largs', and 'values' attributes,
OptionParser is not thread-safe. If, for some perverse reason, you
need to parse command-line arguments simultaneously in different
threads, use different OptionParser instances.
RcCs�tj||||�|j|�| |_||_t|_t|_|dkr_t �}n||_
|j
j|�|
|_|j
|d|�|j�dS(Ntadd_help(RRt set_usagetprogR�R�tallow_interspersed_argstprocess_default_valuesR&R RR;RRt_populate_option_listt_init_parsing_state(RRERiRR�RRPRtadd_help_optionR!RR((s/sys/lib/python2.7/optparse.pyR�s
cCsAtj|�x|jD]}|j�qW|`|`|`dS(s
Declare that you are done with this OptionParser. This cleans up
reference cycles so the OptionParser (and all objects referenced by
it) can be garbage-collected promptly. After calling destroy(), the
OptionParser is unusable.
N(RRRkRiR(RRo((s/sys/lib/python2.7/optparse.pyR�s
cCs g|_g|_|j�dS(N(RiRkR(R((s/sys/lib/python2.7/optparse.pyR��s cCs&|jdddddtd��dS(Ns-hs--helpR�RTsshow this help message and exit(RR (R((s/sys/lib/python2.7/optparse.pyt_add_help_option�scCs#|jddddtd��dS(Ns --versionR�R�RTs&show program's version number and exit(RR (R((s/sys/lib/python2.7/optparse.pyt_add_version_option�scCs_|jr|j|j�n|r2|j|�n|jrH|j�n|r[|j�ndS(N(tstandard_option_listRR�R(R'(RRiR((s/sys/lib/python2.7/optparse.pyR$�s
cCsd|_d|_d|_dS(N(R&trargstlargsR�(R((s/sys/lib/python2.7/optparse.pyR%�s cCsh|dkrtd�|_nF|tkr6d|_n.|j�jd�r[|d|_n ||_dS(Ns%prog [options]susage: i(R&R RERR~R
(RRE((s/sys/lib/python2.7/optparse.pyR �scCs
t|_dS(sSet parsing to not stop on the first non-option, allowing
interspersing switches with command arguments. This is the
default behavior. See also disable_interspersed_args() and the
class documentation description of the attribute
allow_interspersed_args.N(R�R"(R((s/sys/lib/python2.7/optparse.pytenable_interspersed_argsscCs
t|_dS(s�Set parsing to stop on the first non-option. Use this if
you have a command processor which runs another command that
has options of its own and you want to make sure these options
don't get confused.
N(R�R"(R((s/sys/lib/python2.7/optparse.pytdisable_interspersed_argsscCs
||_dS(N(R#(RR�((s/sys/lib/python2.7/optparse.pytset_process_default_valuesscCs||j|<dS(N(RU(RRWR�((s/sys/lib/python2.7/optparse.pytset_defaultscKs|jj|�dS(N(RUR�(RR�((s/sys/lib/python2.7/optparse.pytset_defaultsscCs2|j}x!|jD]}|j|j�qW|S(N(RiRkR`(RtoptionsRo((s/sys/lib/python2.7/optparse.pyt_get_all_options!s
cCs�|jst|j�S|jj�}xZ|j�D]L}|j|j�}t|�r2|j�}|j ||�||j<q2q2Wt|�S(N(
R#RRUtcopyR2RVRWR�R�R�(RRURR�R((s/sys/lib/python2.7/optparse.pytget_default_values's
cOs�t|d�tjkr.t|||�}nit|�dkr�|r�|d}t|t�sptd|�n|j|k r�td�q�n td�|j j
|�|S(Niisnot an OptionGroup instance: %rs"invalid OptionGroup (wrong parser)sinvalid arguments(R�R�R�RR]R�R�R'R-RkR^(RR�R�Ro((s/sys/lib/python2.7/optparse.pytadd_option_group8s
cCsD|jj|�p!|jj|�}|r@|j|k r@|jSdS(N(RRVRRR&(RRR((s/sys/lib/python2.7/optparse.pytget_option_groupHs
cCs |dkrtjdS|SdS(Ni(R&R�targv(RR�((s/sys/lib/python2.7/optparse.pyt _get_argsRscCs�|j|�}|dkr*|j�}n||_g|_}||_y|j|||�}Wn,ttfk
r�}|j t
|��nX||}|j||�S(sS
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.
N(R8R&R4R*R+R�t
_process_argsRRRRtcheck_values(RR�R�R*R+tstopterr((s/sys/lib/python2.7/optparse.pyt
parse_argsXs
cCs
||fS(s�
check_values(values : Values, args : [string])
-> (values : Values, args : [string])
Check that the supplied option values and leftover arguments are
valid. Returns the option values and leftover arguments
(possibly adjusted, possibly completely new -- whatever you
like). Default implementation just returns the passed-in
values; subclasses may override as desired.
((RR�R�((s/sys/lib/python2.7/optparse.pyR:scCs�x�|r�|d}|dkr*|d=dS|dd!dkrP|j||�q|d dkr�t|�dkr�|j||�q|jr�|j|�|d=qdSqWdS(s�_process_args(largs : [string],
rargs : [string],
values : Values)
Process command-line arguments and populate 'values', consuming
options and arguments from 'rargs'. If 'allow_interspersed_args' is
false, stop at the first non-option argument. If true, accumulate any
interspersed non-option arguments in 'largs'.
is--NiiR�(t_process_long_optR]t_process_short_optsR"R^(RR+R*R�targ((s/sys/lib/python2.7/optparse.pyR9�s
"
cCst||j�S(s_match_long_opt(opt : string) -> string
Determine which long option string 'opt' matches, ie. which one
it is an unambiguous abbreviation for. Raises BadOptionError if
'opt' doesn't unambiguously match any long option string.
(t
_match_abbrevR(RRm((s/sys/lib/python2.7/optparse.pyt_match_long_opt�sc
Cs_|jd�}d|krL|jdd�\}}|jd|�t}n|}t}|j|�}|j|}|j�r|j}t |�|kr�dkr�|j
td�|�q|j
td�||f�qE|dkr�jd�} qEt|d|!�} |d|5n&|r?|j
td�|�nd} |j|| ||�dS(NiR@is%s option requires an arguments%s option requires %d argumentss%s option does not take a value(tpopR�tinsertR�R�RBRRqR�R]RR R�R&R�(
RR*R�R@Rmtnext_argthad_explicit_valueRR�R�((s/sys/lib/python2.7/optparse.pyR>�s0
cCso|jd�}t}d}xM|dD]A}d|}|jj|�}|d7}|sgt|��n|j�rA|t|�kr�|jd||�t}n|j } t|�| kr| dkr�j
td�|�q>|j
td�|| f�qG| dkr!|jd�}
qGt|d| !�}
|d| 5nd}
|j||
||�|r&Pq&q&WdS(NiiR�s%s option requires an arguments%s option requires %d arguments(RCR�RRVRRqR]RDR�R�RR R�R&R�(RR*R�R@R;titchRmRR�R�((s/sys/lib/python2.7/optparse.pyR?�s6
cCs1|jdkr&tjjtjd�S|jSdS(Ni(R!R&R*tpathtbasenameR�R7(R((s/sys/lib/python2.7/optparse.pyt
get_prog_namescCs|jd|j��S(Ns%prog(RZRK(Rts((s/sys/lib/python2.7/optparse.pytexpand_prog_namescCs|j|j�S(N(RMRP(R((s/sys/lib/python2.7/optparse.pyR sicCs*|rtjj|�ntj|�dS(N(R�tstderrtwriteR�(RtstatusR((s/sys/lib/python2.7/optparse.pyR�#scCs4|jtj�|jdd|j�|f�dS(s�error(msg : string)
Print a usage message incorporating 'msg' to stderr and exit.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception.
is%s: error: %s
N(tprint_usageR�RNR�RK(RR((s/sys/lib/python2.7/optparse.pyR(scCs-|jr%|jj|j|j��SdSdS(NR<(RERRFRM(R((s/sys/lib/python2.7/optparse.pyt get_usage2s cCs |jr||j�IJndS(saprint_usage(file : file = stdout)
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.
N(RERR(Rtfile((s/sys/lib/python2.7/optparse.pyRQ9s cCs!|jr|j|j�SdSdS(NR<(R�RM(R((s/sys/lib/python2.7/optparse.pytget_versionEs cCs |jr||j�IJndS(sEprint_version(file : file = stdout)
Print the version message for this program (self.version) to
'file' (default stdout). As with print_usage(), any occurrence
of "%prog" in self.version is replaced by the current program's
name. Does nothing if self.version is empty or undefined.
N(R�RT(RRS((s/sys/lib/python2.7/optparse.pyR�Ks cCs�|dkr|j}n|j|�g}|j|jtd���|j�|jr�|jtj ||��|jd�nx4|j
D])}|j|j|��|jd�q�W|j�dj
|d �S(NtOptionss
R<i�(R&RRpR^RHR RBRiRRRkRRCR#(RRRaRo((s/sys/lib/python2.7/optparse.pyRVs
cCs|j|j�S(N(RSRR(RR((s/sys/lib/python2.7/optparse.pyRSgscCs�|dkr|j}ng}|jrA|j|j�d�n|jrg|j|j|�d�n|j|j|��|j|j|��dj |�S(Ns
R<(
R&RRER^RRRPRQRRSR#(RRRa((s/sys/lib/python2.7/optparse.pyRjs cCs+t|dd�}|s'tj�}n|S(Ntencoding(R�R&R�tgetdefaultencoding(RRSRV((s/sys/lib/python2.7/optparse.pyt
_get_encodingwscCsJ|dkrtj}n|j|�}|j|j�j|d��dS(s�print_help(file : file = stdout)
Print an extended help message, listing all options and any
help text provided with them, to 'file' (default stdout).
RZN(R&R�tstdoutRXRORtencode(RRSRV((s/sys/lib/python2.7/optparse.pyR�}sN(-RRRR)R&RR�RRR�R'R(R$R%R R,R-R.R/R0R2R4R5R6R8R=R:R9RBR>R?RKRMRR�RRRRQRTR�RRSRRXR�(((s/sys/lib/python2.7/optparse.pyR_sbD
'
3 % *
cCs�||kr|Sg|j�D]}|j|�r|^q}t|�dkrX|dS|smt|��n|j�t||��dS(s�_match_abbrev(s : string, wordmap : {string : Option}) -> string
Return the string key in 'wordmap' for which 's' is an unambiguous
abbreviation. If 's' is found to be ambiguous or doesn't match any of
'words', raise BadOptionError.
iiN(R�R
R]RR�R!(RLtwordmaptwordR"((s/sys/lib/python2.7/optparse.pyRA�s
(+Rt__version__t__all__t
__copyright__R�R*R�RKRRtImportErrorR t ExceptionRRR
RRR!RR R
R�R�R�R�R�R�R�R�RXRRRR�t NameErrorR�RRRRRAR(((s/sys/lib/python2.7/optparse.pyt<module>s~
�
�
A��.
|