ROOTPLOIT
Server: LiteSpeed
System: Linux server71.web-hosting.com 4.18.0-513.18.1.lve.el8.x86_64 #1 SMP Thu Feb 22 12:55:50 UTC 2024 x86_64
User: niphet (1079)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: //usr/lib64/python3.8/__pycache__/optparse.cpython-38.opt-1.pyc
U

e5d@sdZdZdddddddd	d
ddd
dddddgZdZddlZddlZddlZddZzddlmZm	Z	Wn$e
k
rddZddZ	YnXeZGdd
d
eZ
Gddde
ZGdddeZGd dde
ZGd!dde
ZGd"d#d#eZGd$d
d
ZGd%ddeZGd&ddeZd'd(Zd)d*Zeed+feed+feed,feed-fd.Zd/d0Zd1dZd2ZGd3ddZd4Zd5Z Gd6ddZ!Gd7ddZ"Gd8dde"Z#Gd9d	d	e"Z$d:d;Z%eZ&dS)<aA 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()
z1.5.3Optionmake_option
SUPPRESS_HELPSUPPRESS_USAGEValuesOptionContainerOptionGroupOptionParser
HelpFormatterIndentedHelpFormatterTitledHelpFormatter
OptParseErrorOptionErrorOptionConflictErrorOptionValueErrorBadOptionErrorcheck_choicea"
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.
NcCsd|jjt||fS)Nz<%s at 0x%x: %s>)	__class____name__idselfr /usr/lib64/python3.8/optparse.py_reprOsr)gettextngettextcCs|SNr)messagerrrr\srcCs|dkr|S|SNr)ZsingularZpluralnrrrr_src@seZdZddZddZdS)rcCs
||_dSrmsgrr#rrr__init__hszOptParseError.__init__cCs|jSrr"rrrr__str__kszOptParseError.__str__N)r
__module____qualname__r%r&rrrrrgsc@s eZdZdZddZddZdS)r
z]
    Raised if an Option instance is created with invalid or
    inconsistent arguments.
    cCs||_t||_dSr)r#str	option_id)rr#optionrrrr%uszOptionError.__init__cCs |jrd|j|jfS|jSdS)Nz
option %s: %s)r*r#rrrrr&yszOptionError.__str__Nrr'r(__doc__r%r&rrrrr
osc@seZdZdZdS)rzE
    Raised if conflicting options are added to an OptionParser.
    Nrr'r(r-rrrrrsc@seZdZdZdS)rzS
    Raised if an invalid option value is encountered on the command
    line.
    Nr.rrrrrsc@s eZdZdZddZddZdS)rzB
    Raised if an invalid option is seen on the command line.
    cCs
||_dSr)opt_strrr/rrrr%szBadOptionError.__init__cCstd|jS)Nzno such option: %s)_r/rrrrr&szBadOptionError.__str__Nr,rrrrrsc@s eZdZdZddZddZdS)AmbiguousOptionErrorzD
    Raised if an ambiguous option is seen on the command line.
    cCst||||_dSr)rr%
possibilities)rr/r3rrrr%szAmbiguousOptionError.__init__cCstd|jd|jfS)Nzambiguous option: %s (%s?), )r1r/joinr3rrrrr&szAmbiguousOptionError.__str__Nr,rrrrr2sr2c@seZdZdZdZddZddZddZd	d
ZddZ	d
dZ
ddZddZddZ
ddZddZddZddZddZdd Zd!S)"r	a
    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").
    Znonec	Csd|_||_|dkrLzttjd}Wnttfk
rBd}YnX|d8}||_t|t	|d|d|_
|_d|_d|_
d|_||_d|_i|_d|_d|_dS)	NZCOLUMNSPrz%defaultz%s %sz%s=%s)parserindent_incrementintosenvironKeyError
ValueErrorwidthminmax
help_positionmax_help_positioncurrent_indentlevel
help_widthshort_firstdefault_tagoption_strings_short_opt_fmt
_long_opt_fmtrr:rDr@rHrrrr%s&

zHelpFormatter.__init__cCs
||_dSr)r9rr9rrr
set_parserszHelpFormatter.set_parsercCs&|dkrtd|d|d|_dS)N) z/invalid metavar delimiter for short options: %r%s)r?rKrZdelimrrrset_short_opt_delimiters
z%HelpFormatter.set_short_opt_delimitercCs&|dkrtd|d|d|_dS)N)=rQz.invalid metavar delimiter for long options: %rrR)r?rLrSrrrset_long_opt_delimiters
z$HelpFormatter.set_long_opt_delimitercCs"|j|j7_|jd7_dSrrEr:rFrrrrindentszHelpFormatter.indentcCs"|j|j8_|jd8_dSrrWrrrrdedentszHelpFormatter.dedentcCstddSNzsubclasses must implementNotImplementedErrorrusagerrrformat_usageszHelpFormatter.format_usagecCstddSrZr[rZheadingrrrformat_headingszHelpFormatter.format_headingcCs.t|j|jd}d|j}tj||||dS)z
        Format a paragraph of free-form text for inclusion in the
        help output at the current indentation level.
        rQ)Zinitial_indentZsubsequent_indent)rBr@rEtextwrapZfill)rtextZ
text_widthrXrrr_format_texts
zHelpFormatter._format_textcCs|r||dSdSdSN
rPrerdescriptionrrrformat_descriptionsz HelpFormatter.format_descriptioncCs|rd||dSdSdSrfrh)repilogrrr
format_epilogszHelpFormatter.format_epilogcCsP|jdks|js|jS|jj|j}|tks6|dkr<|j}|j|jt	|Sr)
r9rIhelpdefaultsgetdest
NO_DEFAULTNO_DEFAULT_VALUEreplacer))rr+Z
default_valuerrrexpand_defaultszHelpFormatter.expand_defaultcsg}j|}jjd}t||krBdjd|f}j}ndjd||f}d}|||jr|}t|j	}|d|d|df|
fdd|ddDn|d	d
kr|d
d|S)Nr7%*s%s
rPz	%*s%-*s  rcsg|]}djd|fqS)rvrP)rC).0linerrr
<listcomp>Esz/HelpFormatter.format_option.<locals>.<listcomp>r rg)rJrCrElenappendrnrurcZwraprGextendr5)rr+resultoptsZ	opt_widthZindent_firstZ	help_textZ
help_linesrrr
format_option(s&





zHelpFormatter.format_optioncCs|d}|jD],}||}||j|<t|t||j}q||jD]8}|jD],}||}||j|<t|t||j}qXqN||t	|d|j
|_t|j|jd|_
dS)Nrr7rb)rXoption_listformat_option_stringsrJrBr{rE
option_groupsrYrArDrCr@rG)rr9Zmax_lenoptZstringsgrouprrrstore_option_stringsKs 






z"HelpFormatter.store_option_stringscst|rF|jp|jfdd|jD}fdd|jD}n|j}|j}jrb||}n||}d|S)z@Return a comma-separated list of option strings & metavariables.csg|]}j|fqSr)rK)rwZsoptmetavarrrrryasz7HelpFormatter.format_option_strings.<locals>.<listcomp>csg|]}j|fqSr)rL)rwZloptrrrrycsr4)takes_valuerrqupper_short_opts
_long_optsrHr5)rr+Z
short_optsZ	long_optsrrrrr]s
z#HelpFormatter.format_option_stringsN)rr'r(r-rsr%rOrTrVrXrYr_rarerkrmrurrrrrrrr	s")
#c@s*eZdZdZdddZdd	Zd
dZdS)
r
z.Format help with indented section bodies.
    r7Nr cCst|||||dSrr	r%rMrrrr%tszIndentedHelpFormatter.__init__cCstd|S)Nz
Usage: %s
)r1r]rrrr_|sz"IndentedHelpFormatter.format_usagecCsd|jd|fS)Nz%*s%s:
rP)rEr`rrrrasz$IndentedHelpFormatter.format_heading)r7rNr rr'r(r-r%r_rarrrrr
ps
c@s*eZdZdZdddZddZd	d
ZdS)rz1Format help with underlined section headers.
    rrNcCst|||||dSrrrMrrrr%szTitledHelpFormatter.__init__cCsd|td|fS)Nz%s  %s
ZUsage)rar1r]rrrr_sz TitledHelpFormatter.format_usagecCsd|d|jt|fS)Nz%s
%s
z=-)rFr{r`rrrrasz"TitledHelpFormatter.format_heading)rrNrrrrrrrs
cCsh|dddkrd}nD|dddkrDd}|ddp@d}n|dddkrZd}nd}|||S)	Nr7Z0xZ0b0r 
)lower)valtyperadixrrr
_parse_numsrcCs
t|tSr)rr;)rrrr
_parse_intsrZintegerzfloating-pointcomplex)r;longfloatrcCsHt|j\}}z
||WStk
rBttd|||fYnXdS)Nzoption %s: invalid %s value: %r)_builtin_cvtrr?rr1)r+rvalueZcvtZwhatrrr
check_builtins
rcCs:||jkr|Sdtt|j}ttd|||fdS)Nr4z.option %s: invalid choice: %r (choose from %s))choicesr5mapreprrr1)r+rrrrrrrs
)ZNOZDEFAULTc@seZdZdZdddddddd	d
ddd
gZdZdZdZdZdZ	dZ
eeeeedZ
dZddZddZddZddZddZd d!Zd"d#Zd$d%Zd&d'Zd(d)Zd*d+ZeeeeeeegZd,d-ZeZd.d/Zd0d1Zd2d3Zd4d5Z d6d7Z!d8d9Z"dS):rar
    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
    actionrrqdefaultnargsconstrcallback
callback_argscallback_kwargsrnr)
storestore_const
store_truestore_falser|append_constcountrrnversion)rrrrr|rr)rr|r)rr|)rr)stringr;rrrchoice)r;rrrrNcOsBg|_g|_||}|||||jD]}||q0dSr)rr_check_opt_strings_set_opt_strings
_set_attrs
CHECK_METHODS)rrattrscheckerrrrr%4s



zOption.__init__cCsdd|D}|std|S)NcSsg|]}|r|qSrr)rwrrrrryKsz-Option._check_opt_strings.<locals>.<listcomp>z+at least one option string must be supplied)	TypeError)rrrrrrGszOption._check_opt_stringscCs|D]}t|dkr$td||qt|dkrd|ddkrH|ddksVtd|||j|q|dddkr|ddkstd|||j|qdS)	Nr7z>invalid option string %r: must be at least two characters longr-r zMinvalid short option string %r: must be of the form -x, (x any non-dash char)--zGinvalid long option string %r: must start with --, followed by non-dash)r{r
rr|r)rrrrrrrPs2zOption._set_opt_stringscCsv|jD]F}||kr*t||||||=q|dkr@t||tqt||dq|rrt|}tdd||dS)Nrzinvalid keyword arguments: %sr4)ATTRSsetattrrrsortedkeysr
r5)rrattrrrrres
zOption._set_attrscCs2|jdkrd|_n|j|jkr.td|j|dS)Nrzinvalid action: %r)rACTIONSr
rrrr
_check_actionxs
zOption._check_actioncCs|jdkr0|j|jkr|jdk	r(d|_qd|_n^t|jtrF|jj|_|jdkrVd|_|j|jkrrtd|j||j|jkrtd|j|dS)Nrrr)zinvalid option type: %rz$must not supply a type for action %r)	rrALWAYS_TYPED_ACTIONSr
isinstancerTYPESr

TYPED_ACTIONSrrrr_check_type~s 



zOption._check_typecCsr|jdkrT|jdkr td|qnt|jttfsntdtt|jdd|n|jdk	rntd|j|dS)Nrz/must supply a list of choices for type 'choice'z1choices must be a list of strings ('%s' supplied)'r z#must not supply choices for type %r)rrr
rtuplelistr)splitrrrr
_check_choices$


zOption._check_choicecCs\|j|jkp|jdk	}|jdkrX|rX|jrH|jddddd|_n|jdd|_dS)Nrr7rr1r )r
STORE_ACTIONSrrqrrtr)rrrrr_check_destszOption._check_destcCs*|j|jkr&|jdk	r&td|j|dS)Nz*'const' must not be supplied for action %r)r
CONST_ACTIONSrr
rrrr_check_consts
zOption._check_constcCs<|j|jkr|jdkr8d|_n|jdk	r8td|j|dS)Nr z*'nargs' must not be supplied for action %r)rrrr
rrrr_check_nargss

zOption._check_nargscCs|jdkrrt|js$td|j||jdk	rJt|jtsJtd|j||jdk	rt|jtstd|j|nB|jdk	rtd|j||jdk	rtd||jdk	rtd|dS)Nrzcallback not callable: %rz3callback_args, if supplied, must be a tuple: not %rz4callback_kwargs, if supplied, must be a dict: not %rz.callback supplied (%r) for non-callback optionz.callback_args supplied for non-callback optionz0callback_kwargs supplied for non-callback option)	rcallablerr
rrrrdictrrrr_check_callbacksR








zOption._check_callbackcCsd|j|jS)N/)r5rrrrrrr&szOption.__str__cCs
|jdk	Sr)rrrrrrszOption.takes_valuecCs|jr|jdS|jdSdSNr)rrrrrrget_opt_strings
zOption.get_opt_stringcCs*|j|j}|dkr|S||||SdSr)TYPE_CHECKERrpr)rrrrrrrcheck_valueszOption.check_valuecs:|dk	r6jdkr|Stfdd|DSdS)Nr csg|]}|qSr)r)rwvrrrrrysz(Option.convert_value.<locals>.<listcomp>)rrr)rrrrrr
convert_values
zOption.convert_valuecCs$|||}||j|j||||Sr)rtake_actionrrq)rrrvaluesr9rrrprocessszOption.processc	Cs:|dkrt|||n|dkr2t|||jn|dkrHt||dn|dkr^t||dn|dkrz||g|n|dkr||g|jn|d	krt||||d
dn||dkr|jpd
}|jpi}|j||||f||nF|dkr||n*|dkr(|	|nt
d|jdS)NrrrTrFr|rrrr rrrnrzunknown action %r)rrensure_valuer|rrr
print_helpexit
print_versionr?r)	rrrqrrrr9argskwargsrrrrs4





zOption.take_action)#rr'r(r-rrrrrrrrrrrr%rrrrrrrrrrr&r__repr__rrrrrrrrrrrsl
	
		ZSUPPRESSHELPZ
SUPPRESSUSAGEc@s^eZdZdddZddZeZddZdd	Zd
dZ	dd
Z
dddZdddZddZ
dS)rNcCs&|r"|D]\}}t|||qdSr)itemsr)rrorrrrrr%9szValues.__init__cCs
t|jSr)r)__dict__rrrrr&>szValues.__str__cCs2t|tr|j|jkSt|tr*|j|kStSdSr)rrrrNotImplemented)rotherrrr__eq__Cs



z
Values.__eq__cCs6t|D](}||kr||}|dk	rt|||qdS)z
        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)dirr)rrrZdvalrrr_update_carefulKs
zValues._update_carefulcCs|j|dS)z
        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)rupdate)rrrrr
_update_looseXszValues._update_loosecCs8|dkr||n |dkr(||ntd|dS)NcarefulZloosezinvalid update mode: %r)rrr?)rrmoderrr_update`s
zValues._updatercCs&t|tj|}|t||dSr)
__import__sysmodulesrvars)rmodnamermodrrrread_modulehs
zValues.read_modulecCs&i}tt|||||dSr)execopenreadr)rfilenamerrrrr	read_filemszValues.read_filecCs.t||rt||dkr$t|||t||Sr)hasattrgetattrr)rrrrrrrrszValues.ensure_value)N)r)r)rr'r(r%r&rrrrrrrrrrrrrr7s



c@seZdZdZddZddZddZdd	Zd
dZdd
Z	ddZ
ddZddZddZ
ddZddZddZddZddZd d!Zd"S)#ra
    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 appear 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.

    cCs&|||_||||dSr)_create_option_listoption_classset_conflict_handlerset_description)rrconflict_handlerrjrrrr%s
zOptionContainer.__init__cCsi|_i|_i|_dSr
_short_opt	_long_optrorrrr_create_option_mappingssz'OptionContainer._create_option_mappingscCs|j|_|j|_|j|_dSrrrNrrr_share_option_mappingssz&OptionContainer._share_option_mappingscCs|dkrtd|||_dS)N)errorresolvez$invalid conflict_resolution value %r)r?r)rhandlerrrrrsz$OptionContainer.set_conflict_handlercCs
||_dSrrjrirrrrszOptionContainer.set_descriptioncCs|jSrrrrrrget_descriptionszOptionContainer.get_descriptioncCs|`|`|`dSzsee OptionParser.destroy().NrrrrrdestroyszOptionContainer.destroycCsg}|jD]"}||jkr
|||j|fq
|jD]"}||jkr4|||j|fq4|r|j}|dkrtdddd|D|nd|dkr|D]V\}}|dr|j	||j|=n|j	||j|=|js|js|j
j	|qdS)Nrz conflicting option string(s): %sr4cSsg|]}|dqS)rr)rwcorrrrysz3OptionContainer._check_conflict.<locals>.<listcomp>rr)rrr|rrrrr5
startswithremove	containerr)rr+Z
conflict_optsrr
Zc_optionrrr_check_conflicts2





zOptionContainer._check_conflictcOst|dtr|j||}n8t|dkrL|sL|d}t|tsTtd|ntd|||j|||_	|j
D]}||j|<qv|jD]}||j
|<q|jdk	r|jtk	r|j|j|j<n|j|jkrd|j|j<|S)zOadd_option(Option)
           add_option(opt_str, ..., kwarg=val, ...)
        rr znot an Option instance: %rinvalid argumentsN)rr)rr{rrrrr|rrrrrrqrrrro)rrrr+rrrr
add_options(





zOptionContainer.add_optioncCs|D]}||qdSr)r)rrr+rrradd_optionsszOptionContainer.add_optionscCs|j|p|j|Sr)rrprr0rrr
get_options
zOptionContainer.get_optioncCs||jkp||jkSr)rrr0rrr
has_options
zOptionContainer.has_optioncCsn|j|}|dkr |j|}|dkr4td||jD]}|j|=q:|jD]}|j|=qN|jj|dS)Nzno such option %r)	rrprr?rrrrr)rr/r+rrrr
remove_options



zOptionContainer.remove_optioncCs>|js
dSg}|jD]}|jtk	r|||qd|SNrP)rrnrr|rr5)r	formatterr~r+rrrformat_option_helps

z"OptionContainer.format_option_helpcCs||Sr)rkrrrrrrrk(sz"OptionContainer.format_descriptioncCs:g}|jr||||jr0|||d|S)Nrg)rjr|rkrrr5rrr~rrrformat_help+szOptionContainer.format_helpN)rr'r(r-r%r	r
rrrrrrrrrrrrkr"rrrrrxs"			c@s6eZdZdddZddZddZdd	Zd
dZdS)
rNcCs$||_t||j|j|||_dSr)r9rr%rrtitle)rr9r#rjrrrr%6szOptionGroup.__init__cCsg|_||jdSr)rr
r9rrrrr<szOptionGroup._create_option_listcCs
||_dSr)r#)rr#rrr	set_title@szOptionGroup.set_titlecCst||`dSr)rrrrrrrrCs
zOptionGroup.destroycCs0||j}||t||7}||Sr)rar#rXrr"rYr!rrrr"Js
zOptionGroup.format_help)N)rr'r(r%rr$rr"rrrrr4s

c
@sbeZdZdZgZddedddddddf
ddZddZd	d
ZddZ	d
dZ
dPddZddZddZ
ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(ZdQd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z dRd<d=Z!d>d?Z"d@dAZ#dSdBdCZ$dDdEZ%dTdFdGZ&dUdHdIZ'dJdKZ(dVdLdMZ)dWdNdOZ*dS)Xra$
    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.

    NrTcCsrt|||||||	|_||_d|_d|_|dkr@t}||_|j	||
|_
|j||d|dS)NT)add_help)
rr%	set_usageprograllow_interspersed_argsprocess_default_valuesr
rrOrl_populate_option_list_init_parsing_state)rr^rrrrrjrZadd_help_optionr'rlrrrr%s(
zOptionParser.__init__cCs.t||jD]}|q|`|`|`dS)a
        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)rrrrr)rrrrrrs


zOptionParser.destroycCsg|_g|_|dSr)rrr	rrrrrsz OptionParser._create_option_listcCs|jdddtdddS)Nz-hz--helprnzshow this help message and exitrrnrr1rrrr_add_help_optionszOptionParser._add_help_optioncCs|jddtdddS)Nz	--versionrz&show program's version number and exitr,r-rrrr_add_version_optionsz OptionParser._add_version_optioncCs>|jr||j|r |||jr.||r:|dSr)standard_option_listrrr/r.)rrr%rrrr*s
z"OptionParser._populate_option_listcCsd|_d|_d|_dSr)rargslargsrrrrrr+sz OptionParser._init_parsing_statecCsL|dkrtd|_n4|tkr$d|_n$|drB|dd|_n||_dS)Nz%prog [options]zusage: )r1r^rrrr]rrrr&szOptionParser.set_usagecCs
d|_dS)aSet 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.TNr(rrrrenable_interspersed_argssz%OptionParser.enable_interspersed_argscCs
d|_dS)zSet 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.
        FNr4rrrrdisable_interspersed_argssz&OptionParser.disable_interspersed_argscCs
||_dSr)r))rrrrrset_process_default_valuessz'OptionParser.set_process_default_valuescCs||j|<dSr)ro)rrqrrrrset_defaultszOptionParser.set_defaultcKs|j|dSr)ror)rrrrrset_defaultsszOptionParser.set_defaultscCs*|jdd}|jD]}||jq|Sr)rrr})rZoptionsrrrr_get_all_optionss
zOptionParser._get_all_optionscCs`|jst|jS|j}|D]4}||j}t|tr"|	}|
||||j<q"t|Sr)r)rrocopyr:rprqrr)rr)rror+rr/rrrget_default_valuess


zOptionParser.get_default_valuescOszt|dtr t|f||}nJt|dkrb|sb|d}t|tsNtd||j|k	rjtdntd|j||S)Nrr znot an OptionGroup instance: %rz"invalid OptionGroup (wrong parser)r)	rr)rr{rr9r?rr|)rrrrrrradd_option_group+s


zOptionParser.add_option_groupcCs0|j|p|j|}|r,|j|k	r,|jSdSr)rrprr)rr/r+rrrget_option_group;s
zOptionParser.get_option_groupcCs&|dkrtjddS|ddSdSr)rargv)rrrrr	_get_argsEszOptionParser._get_argsc
Cs||}|dkr|}||_g|_}||_z||||}Wn4ttfk
rv}z|t	|W5d}~XYnX||}|
||S)aR
        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 a Values instance (with all
        your option values) and 'args' is the list of arguments left
        over after parsing options.
        N)r@r<r1r2r
_process_argsrrrr)check_values)rrrr1r2stoperrrrr
parse_argsKs

 zOptionParser.parse_argscCs||fS)a
        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.
        r)rrrrrrrBrszOptionParser.check_valuescCs|r|d}|dkr|d=dS|dddkr<|||q|dddkrft|dkrf|||q|jr~|||d=qdSqdS)a_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'.
        rrNr7r r)_process_long_optr{_process_short_optsr(r|)rr2r1rargrrrrAs

zOptionParser._process_argscCst||jS)a_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.
        )
_match_abbrevr)rrrrr_match_long_optszOptionParser._match_long_optc
Cs|d}d|kr4|dd\}}|d|d}n|}d}||}|j|}|r|j}t||kr|t	dd|||dq|dkr|d}	qt
|d|}	|d|=n|r|td	|nd}	|||	||dS)
NrrUr TF.%(option)s option requires %(number)d argument/%(option)s option requires %(number)d argumentsr+Znumberz%s option does not take a value)
poprinsertrJrrrr{rrrr1r)
rr1rrHrZnext_argZhad_explicit_valuer+rrrrrrFs6


zOptionParser._process_long_optcCs|d}d}d}|ddD]}d|}|j|}|d7}|sJt||r|t|krv|d||dd}|j}	t||	kr|t	dd|	||	dq|	dkr|d}
qt
|d|	}
|d|	=nd}
|||
|||rqqdS)	NrFr rTrKrLrM)rNrrprrr{rOrrrrr)rr1rrHrCiZchrr+rrrrrrGs<
z OptionParser._process_short_optscCs&|jdkrtjtjdS|jSdSr)r'r<pathbasenamerr?rrrr
get_prog_names
zOptionParser.get_prog_namecCs|d|S)Nz%prog)rtrS)rsrrrexpand_prog_nameszOptionParser.expand_prog_namecCs||jSr)rUrjrrrrrszOptionParser.get_descriptionrcCs|rtj|t|dSr)rstderrwriter)rZstatusr#rrrrszOptionParser.exitcCs(|tj|dd||fdS)zerror(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.
        r7z%s: error: %s
N)print_usagerrVrrSr$rrrrszOptionParser.errorcCs"|jr|j||jSdSdSr)r^rr_rUrrrr	get_usage#s

zOptionParser.get_usagecCs|jrt||ddS)aaprint_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.
        fileN)r^printrYrr[rrrrX*s	zOptionParser.print_usagecCs|jr||jSdSdSr)rrUrrrrget_version6szOptionParser.get_versioncCs|jrt||ddS)aEprint_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.
        rZN)rr\r^r]rrrr<szOptionParser.print_versioncCs|dkr|j}||g}||td||jrZ|t|||d|j	D]}||
||dq`|d|ddS)NZOptionsrgrPrz)
rrr|rar1rXrrrrr"rYr5)rrr~rrrrrGs


zOptionParser.format_option_helpcCs||jSr)rmrlr rrrrmXszOptionParser.format_epilogcCsn|dkr|j}g}|jr*||d|jrD|||d||||||d|Srf)	rr^r|rYrjrkrrmr5r!rrrr"[szOptionParser.format_helpcCs |dkrtj}||dS)zprint_help(file : file = stdout)

        Print an extended help message, listing all options and any
        help text provided with them, to 'file' (default stdout).
        N)rstdoutrWr"r]rrrrgszOptionParser.print_help)T)NN)rN)N)N)N)N)N)+rr'r(r-r0rr%rrr.r/r*r+r&r5r6r7r8r9r:r<r=r>r@rErBrArJrFrGrSrUrrrrYrXr^rrrmr"rrrrrrRsbD
"

	

'
3	$)





csZ|krSfdd|D}t|dkr6|dS|sDtn|t|dS)z_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.
    csg|]}|r|qSr)r)rwZwordrTrrrys
z!_match_abbrev.<locals>.<listcomp>r rN)rr{rsortr2)rTZwordmapr3rr`rrIts
rI)'r-__version____all__Z
__copyright__rr<rcrrrImportErrorr1	Exceptionrr
rrrr2r	r
rrrrrrrrrrrrrrrrrrIrrrrr<module>s 


P




uA=&