Plan 9 from Bell Labs’s /usr/web/sources/contrib/bichued/root/sys/lib/python/optparse.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


�
��c@s�dZdZdddddddd	d
ddd
dddgZdZddkZddkZddkZddkZd�Zyddk	l	Z	Wne
j
od�Z	nXe	Zdefd��YZ
d
e
fd��YZdefd��YZde
fd��YZde
fd��YZdefd��YZd	fd��YZd
efd��YZdefd ��YZd!�Zd"�Zd#�Zheed$�fd%<eed&�fd'<eed(�fd)<eed*�fd*<Zd+�Zd,�Zd-d.fZdfd/��YZd0d1Z d0d2Z!ye"e#fWn%e$j
od3d4f\Z"Z#nXd5�Z%dfd6��YZ&dfd7��YZ'de'fd8��YZ(de'fd9��YZ)d:�Z*eZ+dS(;s�optparse - a powerful, extensible, and easy-to-use option parser.

By Greg Ward <[email protected]>

Originally distributed as Optik; see http://optik.sourceforge.net/ .

If you have problems with this module, please do not file bugs,
patches, or feature requests with Python; instead, use Optik's
SourceForge project page:
  http://sourceforge.net/projects/optik

For support, use the [email protected] mailing list
(http://lists.sourceforge.net/lists/listinfo/optik-users).
s1.5.3tOptiont
SUPPRESS_HELPtSUPPRESS_USAGEtValuestOptionContainertOptionGrouptOptionParsert
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|iit|�|fS(Ns<%s at 0x%x: %s>(t	__class__t__name__tid(tself((s/sys/lib/python/optparse.pyt_reprIs(tgettextcCs|S(N((tmessage((s/sys/lib/python/optparse.pyRVscBseZd�Zd�ZRS(cCs
||_dS(N(tmsg(RR((s/sys/lib/python/optparse.pyt__init__\scCs|iS(N(R(R((s/sys/lib/python/optparse.pyt__str___s(Rt
__module__RR(((s/sys/lib/python/optparse.pyR
[s	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/python/optparse.pyRis	cCs-|iod|i|ifSn|iSdS(Ns
option %s: %s(RR(R((s/sys/lib/python/optparse.pyRms
(RRt__doc__RR(((s/sys/lib/python/optparse.pyRcs	cBseZdZRS(sE
    Raised if conflicting options are added to an OptionParser.
    (RRR(((s/sys/lib/python/optparse.pyRsscBseZdZRS(sS
    Raised if an invalid option value is encountered on the command
    line.
    (RRR(((s/sys/lib/python/optparse.pyR
xscBs eZdZd�Zd�ZRS(sB
    Raised if an invalid option is seen on the command line.
    cCs
||_dS(N(topt_str(RR((s/sys/lib/python/optparse.pyR�scCstd�|iS(Nsno such option: %s(t_R(R((s/sys/lib/python/optparse.pyR�s(RRRRR(((s/sys/lib/python/optparse.pyR~s	tAmbiguousOptionErrorcBs eZdZd�Zd�ZRS(sD
    Raised if an ambiguous option is seen on the command line.
    cCsti||�||_dS(N(RRt
possibilities(RRR!((s/sys/lib/python/optparse.pyR�scCs#td�|idi|i�fS(Nsambiguous option: %s (%s?)s, (RRtjoinR!(R((s/sys/lib/python/optparse.pyR�s	(RRRRR(((s/sys/lib/python/optparse.pyR �s	cBs�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�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|_||_||_|_|djoGyttid�}Wntt	fj
o
d}nX|d8}n||_
d|_d|_d|_
||_d|_h|_d|_d|_dS(NtCOLUMNSiPiis%defaults%s %ss%s=%s(tNonetparsertindent_incrementt
help_positiontmax_help_positiontinttostenvirontKeyErrort
ValueErrortwidthtcurrent_indenttlevelt
help_widthtshort_firsttdefault_tagtoption_stringst_short_opt_fmtt
_long_opt_fmt(RR'R)R/R3((s/sys/lib/python/optparse.pyR�s$		
								cCs
||_dS(N(R&(RR&((s/sys/lib/python/optparse.pyt
set_parser�scCs6|djotd|��nd|d|_dS(Ntt s/invalid metavar delimiter for short options: %rs%s(R9R:(R.R6(Rtdelim((s/sys/lib/python/optparse.pytset_short_opt_delimiter�s
cCs6|djotd|��nd|d|_dS(Nt=R:s.invalid metavar delimiter for long options: %rs%s(R=R:(R.R7(RR;((s/sys/lib/python/optparse.pytset_long_opt_delimiter�s
cCs%|i|i7_|id7_dS(Ni(R0R'R1(R((s/sys/lib/python/optparse.pytindent�scCs?|i|i8_|idjp
td�|id8_dS(NisIndent decreased below 0.i(R0R'tAssertionErrorR1(R((s/sys/lib/python/optparse.pytdedent�scCs
td�dS(Nssubclasses must implement(tNotImplementedError(Rtusage((s/sys/lib/python/optparse.pytformat_usage�scCs
td�dS(Nssubclasses must implement(RB(Rtheading((s/sys/lib/python/optparse.pytformat_heading�scCs9|i|i}d|i}ti||d|d|�S(s�
        Format a paragraph of free-form text for inclusion in the
        help output at the current indentation level.
        R:tinitial_indenttsubsequent_indent(R/R0ttextwraptfill(Rttextt
text_widthR?((s/sys/lib/python/optparse.pyt_format_text�s
	cCs$|o|i|�dSndSdS(Ns
R9(RM(Rtdescription((s/sys/lib/python/optparse.pytformat_descriptionscCs(|od|i|�dSndSdS(Ns
R9(RM(Rtepilog((s/sys/lib/python/optparse.pyt
format_epilog
scCs�|idjp|io|iSn|iii|i�}|tjp
|djo
|i}n|ii	|it
|��S(N(R&R%R4thelptdefaultstgettdestt
NO_DEFAULTtNO_DEFAULT_VALUEtreplaceR(RRt
default_value((s/sys/lib/python/optparse.pytexpand_defaults
c
	CsDg}|i|}|i|id}t|�|jo#d|id|f}|i}n d|id||f}d}|i|�|io�|i|�}ti||i	�}|id|d|df�|i
g}|dD]}	|d|id|	fq��n#|ddjo|id�ndi|�S(	Nis%*s%s
R9s	%*s%-*s  iii�s
(R5R(R0tlentappendRRRZRItwrapR2textendR"(
RRtresulttoptst	opt_widthtindent_firstt	help_textt
help_linest_[1]tline((s/sys/lib/python/optparse.pyt
format_options$




3cCs
|i�d}xI|iD]>}|i|�}||i|<t|t|�|i�}qW|i�x]|iD]R}xI|iD]>}|i|�}||i|<t|t|�|i�}q�WqpW|i�|i�t	|d|i
�|_|i|i|_
dS(Nii(R?toption_listtformat_option_stringsR5tmaxR[R0t
option_groupsRAtminR)R(R/R2(RR&tmax_lentopttstringstgroup((s/sys/lib/python/optparse.pytstore_option_strings>s&


 



$

c
Cs�|i�o|ip
|ii�}g}|iD]}||i||fq4~}g}|iD]}||i||fqe~}n|i}|i}|io||}	n||}	di	|	�S(s@Return a comma-separated list of option strings & metavariables.s, (
ttakes_valuetmetavarRUtuppert_short_optsR6t
_long_optsR7R3R"(
RRRsRetsoptt
short_optst_[2]tloptt	long_optsR`((s/sys/lib/python/optparse.pyRiPs
*.		

(RRRRWRR8R<R>R?RARDRFRMRORQRZRgRqRi(((s/sys/lib/python/optparse.pyR�s")												
	#	cBs5eZdZddddd�Zd�Zd�ZRS(s.Format help with indented section bodies.
    iiicCsti|||||�dS(N(RR(RR'R)R/R3((s/sys/lib/python/optparse.pyRgscCstd�|S(Ns
Usage: %s
(R(RRC((s/sys/lib/python/optparse.pyRDoscCsd|id|fS(Ns%*s%s:
R9(R0(RRE((s/sys/lib/python/optparse.pyRFrsN(RRRR%RRDRF(((s/sys/lib/python/optparse.pyRcs	cBs5eZdZddddd�Zd�Zd�ZRS(s1Format help with underlined section headers.
    iicCsti|||||�dS(N(RR(RR'R)R/R3((s/sys/lib/python/optparse.pyRzscCsd|itd��|fS(Ns%s  %s
tUsage(RFR(RRC((s/sys/lib/python/optparse.pyRD�scCsd|d|it|�fS(Ns%s
%s
s=-(R1R[(RRE((s/sys/lib/python/optparse.pyRF�sN(RRRR%RRDRF(((s/sys/lib/python/optparse.pyR	vs	cCs�|d i�djo
d}nT|d i�djod}|dpd}n"|d djo
d}nd}|||�S(	Nit0xit0bt0iii
(tlower(tvalttypetradix((s/sys/lib/python/optparse.pyt
_parse_num�s

cCs
t|t�S(N(R�R*(R�((s/sys/lib/python/optparse.pyt
_parse_int�scCs
t|t�S(N(R�tlong(R�((s/sys/lib/python/optparse.pyt_parse_long�stintegerR*slong integerR�sfloating-pointtfloattcomplexcCsZt|i\}}y||�SWn2tj
o&ttd�|||f��nXdS(Nsoption %s: invalid %s value: %r(t_builtin_cvtR�R.R
R(RRntvaluetcvttwhat((s/sys/lib/python/optparse.pyt
check_builtin�scCsV||ijo|Sn;ditt|i��}ttd�|||f��dS(Ns, s.option %s: invalid choice: %r (choose from %s)(tchoicesR"tmaptreprR
R(RRnR�R�((s/sys/lib/python/optparse.pytcheck_choice�s	tNOtDEFAULTcBsXeZdZddddddddd	d
ddgZd-Zd.Zd/Zd0Zd1Zd2Z	he
d<e
d<e
d<e
d<ed<Zd3Zd�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�RUtdefaulttnargstconstR�tcallbackt
callback_argstcallback_kwargsRRRststoretstore_constt
store_truetstore_falseR\tappend_consttcounttversiontstringR*R�R�R�tchoicecOs]g|_g|_|i|�}|i|�|i|�x|iD]}||�qEWdS(N(RuRvt_check_opt_stringst_set_opt_stringst
_set_attrst
CHECK_METHODS(RR`tattrstchecker((s/sys/lib/python/optparse.pyR*s		


cCs*td|�}|ptd��n|S(Ns+at least one option string must be supplied(tfilterR%t	TypeError(RR`((s/sys/lib/python/optparse.pyR�=scCs�x�D]�}t|�djotd||��qt|�djoM|ddjo|ddjptd||��n|ii|�q|dd!djo|ddjptd||��n|ii|�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[RRuR\Rv(RR`Rn((s/sys/lib/python/optparse.pyR�Fs&"
%
cCs�xq|iD]f}|i|�ot||||�||=q
|djot||t�q
t||d�q
W|o6|i�}|i�tddi|�|��ndS(NR�sinvalid keyword arguments: %ss, (	tATTRSthas_keytsetattrRVR%tkeystsortRR"(RR�tattr((s/sys/lib/python/optparse.pyR�[s


cCsN|idjo
d|_n.|i|ijotd|i|��ndS(NR�sinvalid action: %r(R�R%tACTIONSR(R((s/sys/lib/python/optparse.pyt
_check_actionos
cCs9|idjoA|i|ijo*|idj	o
d|_qMd|_q5n�ddk}t|i�tijp5t|id�o5t	||ii
d�|ijo|ii
|_n|idjo
d|_n|i|ijotd|i|��n|i|i
jotd|i|��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/python/optparse.pyt_check_typeus"
"
cCs�|idjo||idjotd|��q�t|i�titifjo3tdtt|i��id�d|��q�n+|idj	otd|i|��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/python/optparse.pyt
_check_choice�s"1cCs�|i|ijp
|idj	}|idjoM|oF|io$|iddidd�|_q|idd|_ndS(NiiR�Ri(R�t
STORE_ACTIONSR�R%RURvRXRu(RRr((s/sys/lib/python/optparse.pyt_check_dest�s
$cCsA|i|ijo*|idj	otd|i|��ndS(Ns*'const' must not be supplied for action %r(R�t
CONST_ACTIONSR�R%R(R((s/sys/lib/python/optparse.pyt_check_const�s#
cCsb|i|ijo!|idjo
d|_q^n+|idj	otd|i|��ndS(Nis*'nargs' must not be supplied for action %r(R�R�R�R%R(R((s/sys/lib/python/optparse.pyt_check_nargs�s
cCs8|idjo�t|i�ptd|i|��n|idj	o3t|i�tij	otd|i|��n|i	dj	o3t|i	�ti
j	otd|i	|��q4nq|idj	otd|i|��n|idj	otd|��n|i	dj	otd|��ndS(NR�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�tcallableR�RR�R%R�R�R�R�tDictType(R((s/sys/lib/python/optparse.pyt_check_callback�s0cCsdi|i|i�S(Nt/(R"RuRv(R((s/sys/lib/python/optparse.pyR�scCs
|idj	S(N(R�R%(R((s/sys/lib/python/optparse.pyRr�scCs(|io|idSn|idSdS(Ni(RvRu(R((s/sys/lib/python/optparse.pytget_opt_string�s
cCs>|ii|i�}|djo|Sn||||�SdS(N(tTYPE_CHECKERRTR�R%(RRnR�R�((s/sys/lib/python/optparse.pytcheck_value�s
cCsj|dj	oY|idjo|i||�Sqftg}|D]}||i||�q?~�SndS(Ni(R%R�R�ttuple(RRnR�Retv((s/sys/lib/python/optparse.pyt
convert_value�s
cCs4|i||�}|i|i|i||||�S(N(R�ttake_actionR�RU(RRnR�tvaluesR&((s/sys/lib/python/optparse.pytprocesssc	Cs�|djot|||�n�|djot|||i�nr|djot||t�nQ|djot||t�n0|djo|i|g�i|�n|djo |i|g�i|i�n�|djo$t|||i|d�d	�n�|d
jo@|ipd}|iph}|i||||||�n[|djo|i	�|i
�n6|djo|i�|i
�ntd
|i
�d	S(NR�R�R�R�R\R�R�iiR�RRR�sunknown action %r((R�R�tTruetFalsetensure_valueR\R�R�R�t
print_helptexitt
print_versiontRuntimeErrorR�(	RR�RURnR�R�R&targstkwargs((s/sys/lib/python/optparse.pyR�s4





 
$
 



(
sstoresstore_consts
store_truesstore_falsesappendsappend_constscountscallbackshelpsversion(sstoresstore_consts
store_truesstore_falsesappendsappend_constscount(sstoresappendscallback(sstoresappend(sstore_constsappend_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__RrR�R�R�R�R�(((s/sys/lib/python/optparse.pyR�s�	
											
													tSUPPRESStHELPtUSAGEiicCs#t|ti�pt|ti�S(N(t
isinstanceR�t
StringTypetUnicodeType(tx((s/sys/lib/python/optparse.pytisbasestring:scBsheZd
d�Zd�ZeZd�Zd�Zd�Z	d�Z
dd�Zdd�Zd	�Z
RS(cCs<|o1x.|i�D]\}}t|||�qWndS(N(titemsR�(RRSR�R�((s/sys/lib/python/optparse.pyR?s
cCs
t|i�S(N(Rt__dict__(R((s/sys/lib/python/optparse.pyRDscCsVt|t�ot|i|i�Sn,t|ti�ot|i|�SndSdS(Ni�(R�RtcmpR�R�R�(Rtother((s/sys/lib/python/optparse.pyt__cmp__Is
cCsZxSt|�D]E}|i|�o/||}|dj	ot|||�qRq
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%R�(RtdictR�tdval((s/sys/lib/python/optparse.pyt_update_carefulQs


cCs|ii|�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/python/optparse.pyt
_update_loose^scCsM|djo|i|�n,|djo|i|�ntd|�dS(Ntcarefultloosesinvalid update mode: %r(R�R�R.(RR�tmode((s/sys/lib/python/optparse.pyt_updatefs


R�cCs1t|�ti|}|it|�|�dS(N(t
__import__tsystmodulesR�tvars(RtmodnameR�tmod((s/sys/lib/python/optparse.pytread_modulens

cCs'h}t||�|i||�dS(N(texecfileR�(RtfilenameR�R�((s/sys/lib/python/optparse.pyt	read_filess
cCsHt||�pt||�djot|||�nt||�S(N(R�R�R%R�(RR�R�((s/sys/lib/python/optparse.pyR�xs'N(RRR%RRRR�R�R�R�R�R�RR�(((s/sys/lib/python/optparse.pyR=s			
		cBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�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|i�||_|i|�|i|�dS(N(t_create_option_listtoption_classtset_conflict_handlertset_description(RRtconflict_handlerRN((s/sys/lib/python/optparse.pyR�s
	
cCsh|_h|_h|_dS(N(t
_short_optt	_long_optRS(R((s/sys/lib/python/optparse.pyt_create_option_mappings�s		cCs(|i|_|i|_|i|_dS(N(RRRS(RR&((s/sys/lib/python/optparse.pyt_share_option_mappings�scCs+|djotd|�n||_dS(Nterrortresolves$invalid conflict_resolution value %r(serrorR(R.R(Rthandler((s/sys/lib/python/optparse.pyR�s
cCs
||_dS(N(RN(RRN((s/sys/lib/python/optparse.pyR�scCs|iS(N(RN(R((s/sys/lib/python/optparse.pytget_description�scCs|`|`|`dS(ssee OptionParser.destroy().N(RRRS(R((s/sys/lib/python/optparse.pytdestroy�scCs�g}xB|iD]7}|ii|�o|i||i|f�qqWxB|iD]7}|ii|�o|i||i|f�qUqUW|o�i}|djo?tddig}|D]}||dq�~�|��q�|djo�x�|D]\}}|i	d�o|ii
|�|i|=n|ii
|�|i|=|ip|ip|iii
|�qqWq�ndS(NRs conflicting option string(s): %ss, iRs--(
RuRR�R\RvRRRR"t
startswithtremovet	containerRh(RRt
conflict_optsRnR
Retcotc_option((s/sys/lib/python/optparse.pyt_check_conflict�s4
"
"	
,


cOsTt|d�tijo|i||�}nTt|�djo7|o/|d}t|t�ptd|�q�n
td�|i|�|i	i
|�||_x|iD]}||i
|<q�Wx|iD]}||i|<q�W|idj	oU|itj	o|i|i|i<qP|ii|i�pd|i|i<qPn|S(sOadd_option(Option)
           add_option(opt_str, ..., kwarg=val, ...)
        iisnot an Option instance: %rsinvalid argumentsN(R�R�R�RR[R�RR�RRhR\RRuRRvRRUR%R�RVRSR�(RR�R�RRn((s/sys/lib/python/optparse.pyt
add_option�s,
	
	

cCs"x|D]}|i|�qWdS(N(R(RRhR((s/sys/lib/python/optparse.pytadd_optionsscCs#|ii|�p|ii|�S(N(RRTR(RR((s/sys/lib/python/optparse.pyt
get_option
scCs#|ii|�p|ii|�S(N(RR�R(RR((s/sys/lib/python/optparse.pyt
has_optionscCs�|ii|�}|djo|ii|�}n|djotd|��nx|iD]}|i|=q`Wx|iD]}|i|=q~W|iii	|�dS(Nsno such option %r(
RRTR%RR.RuRvRRhR(RRRRn((s/sys/lib/python/optparse.pyt
remove_options



cCsc|ipdSng}x;|iD]0}|itj	o|i|i|��q"q"Wdi|�S(NR9(RhRRRR\RgR"(Rt	formatterR_R((s/sys/lib/python/optparse.pytformat_option_help%s

cCs|i|i��S(N(ROR(RR((s/sys/lib/python/optparse.pyRO.scCs[g}|io|i|i|��n|io|i|i|��ndi|�S(Ns
(RNR\RORhRR"(RRR_((s/sys/lib/python/optparse.pytformat_help1s

(RRRRR	R
RRRRRRRRRRRROR(((s/sys/lib/python/optparse.pyR~s"																		cBs8eZdd�Zd�Zd�Zd�Zd�ZRS(cCs2||_ti||i|i|�||_dS(N(R&RRRRttitle(RR&RRN((s/sys/lib/python/optparse.pyR<s	cCsg|_|i|i�dS(N(RhR
R&(R((s/sys/lib/python/optparse.pyRBs	cCs
||_dS(N(R(RR((s/sys/lib/python/optparse.pyt	set_titleFscCsti|�|`dS(ssee OptionParser.destroy().N(RRRh(R((s/sys/lib/python/optparse.pyRIs
cCs@|i|i�}|i�|ti||�7}|i�|S(N(RFRR?RRRA(RRR_((s/sys/lib/python/optparse.pyRPs


N(RRR%RRR RR(((s/sys/lib/python/optparse.pyR:s
			cBs�eZdZgZd)d)ed)dd)d)ed)d)d�Zd�Zd�Z	d�Z
d�Zed�Zd�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])).
      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�ti||||�|i|�|	|_||_t|_t|_|djo
t	�}n||_
|i
i|�|
|_|i
|d|�|i�dS(Ntadd_help(RRt	set_usagetprogR�R�tallow_interspersed_argstprocess_default_valuesR%RRR8RPt_populate_option_listt_init_parsing_state(RRCRhRR�RRNRtadd_help_optionR#RP((s/sys/lib/python/optparse.pyR�s
				

		cCsAti|�x|iD]}|i�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(RRRkRhR(RRp((s/sys/lib/python/optparse.pyR�s

cCs g|_g|_|i�dS(N(RhRkR	(R((s/sys/lib/python/optparse.pyR�s		cCs&|idddddtd��dS(Ns-hs--helpR�RRsshow this help message and exit(RR(R((s/sys/lib/python/optparse.pyt_add_help_option�scCs#|iddddtd��dS(Ns	--versionR�R�RRs&show program's version number and exit(RR(R((s/sys/lib/python/optparse.pyt_add_version_option�scCsg|io|i|i�n|o|i|�n|io|i�n|o|i�ndS(N(tstandard_option_listRR�R*R)(RRhR!((s/sys/lib/python/optparse.pyR&�s

cCsd|_d|_d|_dS(N(R%trargstlargsR�(R((s/sys/lib/python/optparse.pyR'�s		cCsn|djotd�|_nK|tjo
d|_n1|i�id�o|d|_n
||_dS(Ns%prog [options]susage: i(R%RRCRR�R(RRC((s/sys/lib/python/optparse.pyR"�s


cCs
t|_dS(N(R�R$(R((s/sys/lib/python/optparse.pytenable_interspersed_args�scCs
t|_dS(N(R�R$(R((s/sys/lib/python/optparse.pytdisable_interspersed_args�scCs
||_dS(N(R%(RR�((s/sys/lib/python/optparse.pytset_process_default_valuesscCs||i|<dS(N(RS(RRUR�((s/sys/lib/python/optparse.pytset_defaultscKs|ii|�dS(N(RSR�(RR�((s/sys/lib/python/optparse.pytset_defaultsscCs2|i}x!|iD]}|i|i�qW|S(N(RhRkR^(RtoptionsRp((s/sys/lib/python/optparse.pyt_get_all_optionss


cCs�|ipt|i�Sn|ii�}x\|i�D]N}|i|i�}t|�o)|i�}|i	||�||i<q7q7Wt|�S(N(
R%RRStcopyR4RTRUR�R�R�(RRSRR�R((s/sys/lib/python/optparse.pytget_default_valuess


!cOs�t|d�tijot|||�}nqt|�djoT|oL|d}t|t�ptd|�n|i|j	o
td�q�n
td�|i	i
|�|S(Niisnot an OptionGroup instance: %rs"invalid OptionGroup (wrong parser)sinvalid arguments(R�R�R�RR[R�R�R&R.RkR\(RR�R�Rp((s/sys/lib/python/optparse.pytadd_option_group"s
	cCsK|ii|�p|ii|�}|o|i|j	o|iSndS(N(RRTRRR%(RRR((s/sys/lib/python/optparse.pytget_option_group2s
cCs%|djotidSn|SdS(Ni(R%R�targv(RR�((s/sys/lib/python/optparse.pyt	_get_args<s
cCs�|i|�}|djo|i�}n||_g|_}||_y|i|||�}Wn.ttfj
o}|i	t
|��nX||}|i||�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(R:R%R6R,R-R�t
_process_argsRR
RRtcheck_values(RR�R�R,R-tstopterr((s/sys/lib/python/optparse.pyt
parse_argsBs
	
	
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/python/optparse.pyR<iscCs�x�|o�|d}|djo|d=dSq|dd!djo|i||�q|d djo't|�djo|i||�q|io|i|�|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/python/optparse.pyR;vs



$

cCst||i�S(s_match_long_opt(opt : string) -> string

        Determine which long option string 'opt' matches, ie. which one
        it is an unambiguous abbrevation for.  Raises BadOptionError if
        'opt' doesn't unambiguously match any long option string.
        (t
_match_abbrevR(RRn((s/sys/lib/python/optparse.pyt_match_long_opt�sc
Csk|id�}d|jo2|idd�\}}|id|�t}n
|}t}|i|�}|i|}|i�o�|i}t	|�|joI|djo|i
td�|�q%|i
td�||f�qQ|djo|id�}	qQt|d|!�}	|d|5n)|o|i
td�|�nd}	|i||	||�dS(NiR=is%s option requires an arguments%s option requires %d argumentss%s option does not take a value(tpopR�tinsertR�R�RDRRrR�R[RRR�R%R�(
RR,R�RBRntnext_argthad_explicit_valueRR�R�((s/sys/lib/python/optparse.pyR@�s0



	

c	Cs}|id�}t}d}x[|dD]O}d|}|ii|�}|d7}|pt|��n|i�o�|t|�jo|id||�t}n|i	}	t|�|	joI|	djo|i
td�|�qI|i
td�||	f�qS|	djo|id�}
qSt|d|	!�}
|d|	5nd}
|i||
||�|oPq&q&WdS(NiiR�s%s option requires an arguments%s option requires %d arguments(RER�RRTRRrR[RFR�R�RRR�R%R�(RR,R�RBR=titchRnRR�R�((s/sys/lib/python/optparse.pyRA�s8



	

cCs6|idjotiitid�Sn|iSdS(Ni(R#R%R+tpathtbasenameR�R9(R((s/sys/lib/python/optparse.pyt
get_prog_namescCs|id|i��S(Ns%prog(RXRM(Rts((s/sys/lib/python/optparse.pytexpand_prog_namescCs|i|i�S(N(RORN(R((s/sys/lib/python/optparse.pyR
sicCs,|otii|�nti|�dS(N(R�tstderrtwriteR�(RtstatusR((s/sys/lib/python/optparse.pyR�
scCs4|iti�|idd|i�|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�RPR�RM(RR((s/sys/lib/python/optparse.pyRscCs2|io |ii|i|i��SndSdS(NR9(RCRRDRO(R((s/sys/lib/python/optparse.pyt	get_usages
	cCs"|io||i�IJndS(s`print_usage(file : file = stdout)

        Print the usage message for the current program (self.usage) to
        'file' (default stdout).  Any occurence 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(RCRT(Rtfile((s/sys/lib/python/optparse.pyRS#s	
cCs&|io|i|i�SndSdS(NR9(R�RO(R((s/sys/lib/python/optparse.pytget_version/s
cCs"|io||i�IJndS(sDprint_version(file : file = stdout)

        Print the version message for this program (self.version) to
        'file' (default stdout).  As with print_usage(), any occurence
        of "%prog" in self.version is replaced by the current program's
        name.  Does nothing if self.version is empty or undefined.
        N(R�RV(RRU((s/sys/lib/python/optparse.pyR�5s
cCs�|djo
|i}n|i|�g}|i|itd���|i�|io*|iti	||��|id�nx4|i
D])}|i|i|��|id�q�W|i�di
|d �S(NtOptionss
R9i�(R%RRqR\RFRR?RhRRRkRRAR"(RRR_Rp((s/sys/lib/python/optparse.pyR@s






cCs|i|i�S(N(RQRP(RR((s/sys/lib/python/optparse.pyRQQscCs�|djo
|i}ng}|io|i|i�d�n|io|i|i|�d�n|i|i|��|i|i|��di	|�S(Ns
R9(
R%RRCR\RTRNRORRQR"(RRR_((s/sys/lib/python/optparse.pyRTs



cCs-t|dd�}|pti�}n|S(Ntencoding(R�R%R�tgetdefaultencoding(RRURX((s/sys/lib/python/optparse.pyt
_get_encodingascCsL|djo
ti}n|i|�}|i|i�i|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).
        RXN(R%R�tstdoutRZRQRtencode(RRURX((s/sys/lib/python/optparse.pyR�gs

N(-RRRR+R%RR�RRRR)R*R&R'R"R.R/R0R1R2R4R6R7R8R:R?R<R;RDR@RARMRORR�RRTRSRVR�RRQRRZR�(((s/sys/lib/python/optparse.pyRXsb?				
												
	'	
	3			%	*				
			
	cCs�|i|�o|Sn�g}|i�D]!}|i|�o||q)q)~}t|�djo|dSn1|pt|��n|i�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�RR[RR�R (RNtwordmapRetwordR!((s/sys/lib/python/optparse.pyRCus$
(,Rt__version__t__all__t
__copyright__R�R+R�RIRRtImportErrorRt	ExceptionR
RRR
RR RRR	R�R�R�R�R�R�R�R�RVRRRR�R�t	NameErrorR�RRRRRCtmake_option(((s/sys/lib/python/optparse.pys<module>s|	 	


�	
				�
	A��	

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].