HEX

Warning: set_time_limit() [function.set-time-limit]: Cannot set time limit - prohibited by configuration in /home/u547966/brikov.ru/www/wp-content/plugins/admin-menu-editor/menu-editor.php on line 745
Server: Apache
System: Linux 4.19.0-0.bpo.9-amd64 x86_64 at red40
User: u547966 (5490)
PHP: 5.3.29-mh2
Disabled: syslog, dl, popen, proc_open, proc_nice, proc_get_status, proc_close, proc_terminate, posix_mkfifo, chown, chgrp, accelerator_reset, opcache_reset, accelerator_get_status, opcache_get_status, pcntl_alarm, pcntl_fork, pcntl_waitpid, pcntl_wait, pcntl_wifexited, pcntl_wifstopped, pcntl_wifsignaled, pcntl_wifcontinued, pcntl_wexitstatus, pcntl_wtermsig, pcntl_wstopsig, pcntl_signal, pcntl_signal_dispatch, pcntl_get_last_error, pcntl_strerror, pcntl_sigprocmask, pcntl_sigwaitinfo, pcntl_sigtimedwait, pcntl_exec, pcntl_getpriority, pcntl_setpriority
Upload Files
File: //usr/lib/python3.5/__pycache__/optparse.cpython-35.pyc


Fa@sdZdZdddddddd	d
ddd
ddddgZdZddlZddlZddlZddZyddlmZm	Z	Wn*e
k
rddZddZ	YnXeZGdd
d
eZ
Gddde
ZGdddeZGddde
ZGd dde
ZGd!d"d"eZGd#d
d
ZGd$ddeZGd%ddeZd&d'Zd(d)Zd*eed+fd,eed+fd-eed.fd/eed/fiZd0d1Zd2d3Zd4d5fZGd6ddZd7d8Zd7d9Z Gd:ddZ!Gd;ddZ"Gd<dde"Z#Gd=d	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
OptParseErrorOptionErrorOptionConflictErrorOptionValueErrorBadOptionErrora"
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__id)selfr/usr/lib/python3.5/optparse.py_reprNsr)gettextngettextcCs|S)Nr)messagerrrr[srcCs|dkr|S|S)Nr)ZsingularZpluralnrrrr^src@s(eZdZddZddZdS)rcCs
||_dS)N)msg)rrrrr__init__gszOptParseError.__init__cCs|jS)N)r)rrrr__str__jszOptParseError.__str__N)r
__module____qualname__rr rrrrrfsc@s.eZdZdZddZddZdS)r
z]
    Raised if an Option instance is created with invalid or
    inconsistent arguments.
    cCs||_t||_dS)N)rstr	option_id)rroptionrrrrts	zOptionError.__init__cCs(|jrd|j|jfS|jSdS)Nz
option %s: %s)r$r)rrrrr xs	zOptionError.__str__N)rr!r"__doc__rr rrrrr
nsc@seZdZdZdS)rzE
    Raised if conflicting options are added to an OptionParser.
    N)rr!r"r&rrrrr~sc@seZdZdZdS)rzS
    Raised if an invalid option value is encountered on the command
    line.
    N)rr!r"r&rrrrrsc@s.eZdZdZddZddZdS)rzB
    Raised if an invalid option is seen on the command line.
    cCs
||_dS)N)opt_str)rr'rrrrszBadOptionError.__init__cCstd|jS)Nzno such option: %s)_r')rrrrr szBadOptionError.__str__N)rr!r"r&rr rrrrrsc@s.eZdZdZddZddZdS)AmbiguousOptionErrorzD
    Raised if an ambiguous option is seen on the command line.
    cCstj||||_dS)N)rr
possibilities)rr'r*rrrrszAmbiguousOptionError.__init__cCs#td|jdj|jfS)Nzambiguous option: %s (%s?)z, )r(r'joinr*)rrrrr s	zAmbiguousOptionError.__str__N)rr!r"r&rr rrrrr)sr)c@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").
    ZnonecCsd|_||_|dkr`yttjd}Wnttfk
rUd}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_fmt)rr0r:r6r>rrrrs$		
	*							zHelpFormatter.__init__cCs
||_dS)N)r/)rr/rrr
set_parserszHelpFormatter.set_parsercCs1|dkrtd|d|d|_dS)N z/invalid metavar delimiter for short options: %rz%s)rDrE)r5rA)rdelimrrrset_short_opt_delimiters
z%HelpFormatter.set_short_opt_delimitercCs1|dkrtd|d|d|_dS)N=rEz.invalid metavar delimiter for long options: %rz%s)rHrE)r5rB)rrFrrrset_long_opt_delimiters
z$HelpFormatter.set_long_opt_delimitercCs%|j|j7_|jd7_dS)Nr)r;r0r<)rrrrindentszHelpFormatter.indentcCs@|j|j8_|jdks-td|jd8_dS)NrzIndent decreased below 0.r)r;r0AssertionErrorr<)rrrrdedentszHelpFormatter.dedentcCstddS)Nzsubclasses must implement)NotImplementedError)rusagerrrformat_usageszHelpFormatter.format_usagecCstddS)Nzsubclasses must implement)rM)rheadingrrrformat_headingszHelpFormatter.format_headingcCsBt|j|jd}d|j}tj||d|d|S)z
        Format a paragraph of free-form text for inclusion in the
        help output at the current indentation level.
        rEZinitial_indentZsubsequent_indent)r8r6r;textwrapZfill)rtextZ
text_widthrJrrr_format_texts
	zHelpFormatter._format_textcCs|r|j|dSdSdS)N
rD)rU)rdescriptionrrrformat_descriptionsz HelpFormatter.format_descriptioncCs#|rd|j|dSdSdS)NrVrD)rU)repilogrrr
format_epilogszHelpFormatter.format_epilogcCsu|jdks|jr |jS|jjj|j}|tksP|dkrY|j}|jj|jt	|S)N)
r/r?helpdefaultsgetdest
NO_DEFAULTNO_DEFAULT_VALUEreplacer#)rr%Z
default_valuerrrexpand_defaults	zHelpFormatter.expand_defaultcs)g}j|}jjd}t||kr[djd|f}j}ndjd||f}d}|j||jrj|}tj|j	}|jd|d|df|j
fdd|ddDn|d
d	kr|jd	dj|S)Nr-z%*s%s
rDz	%*s%-*s  rcs&g|]}djd|fqS)z%*s%s
rD)r9).0line)rrr
<listcomp>Ds	z/HelpFormatter.format_option.<locals>.<listcomp>rrV)r@r9r;lenappendr[rbrSZwrapr=extendr+)rr%resultoptsZ	opt_widthZindent_firstZ	help_textZ
help_linesr)rr
format_option's$

	
zHelpFormatter.format_optioncCs|jd}xI|jD]>}|j|}||j|<t|t||j}qW|jx]|jD]R}xI|jD]>}|j|}||j|<t|t||j}qWqpW|j|jt	|d|j
|_t|j|jd|_
dS)Nrr-rR)rJoption_listformat_option_stringsr@r8rgr;
option_groupsrLr7r:r9r6r=)rr/Zmax_lenoptZstringsgrouprrrstore_option_stringsJs 

 

$

z"HelpFormatter.store_option_stringscs|jre|jp!|jjfdd|jD}fdd|jD}n|j}|j}jr||}n
||}dj|S)z@Return a comma-separated list of option strings & metavariables.cs#g|]}j|fqSr)rA)rcZsopt)metavarrrrre`s	z7HelpFormatter.format_option_strings.<locals>.<listcomp>cs#g|]}j|fqSr)rB)rcZlopt)rsrrrrebs	z, )takes_valuersr^upper_short_opts
_long_optsr>r+)rr%Z
short_optsZ	long_optsrkr)rsrrrn\s
			

z#HelpFormatter.format_option_stringsN)rr!r"r&r`rrCrGrIrJrLrOrQrUrXrZrbrlrrrnrrrrr	s")
#c@sFeZdZdZddddddZdd	Zd
dZdS)r
z.Format help with indented section bodies.
    r-NrcCstj|||||dS)N)r	r)rr0r:r6r>rrrrsszIndentedHelpFormatter.__init__cCstd|S)Nz
Usage: %s
)r()rrNrrrrO{sz"IndentedHelpFormatter.format_usagecCsd|jd|fS)Nz%*s%s:
rD)r;)rrPrrrrQ~sz$IndentedHelpFormatter.format_heading)rr!r"r&rrOrQrrrrr
osc@sFeZdZdZddddddZddZd	d
ZdS)rz1Format help with underlined section headers.
    rrxNcCstj|||||dS)N)r	r)rr0r:r6r>rrrrszTitledHelpFormatter.__init__cCsd|jtd|fS)Nz%s  %s
ZUsage)rQr()rrNrrrrOsz TitledHelpFormatter.format_usagecCsd|d|jt|fS)Nz%s
%s
z=-)r<rg)rrPrrrrQsz"TitledHelpFormatter.format_heading)rr!r"r&rrOrQrrrrrscCs|ddjdkr%d}n`|ddjdkr`d}|ddpZd}n%|dddkrd}nd}|||S)	Nr-Z0xZ0b0r
)lower)valtyperadixrrr
_parse_nums		rcCs
t|tS)N)rr1)r~rrr
_parse_intsrr1Zintegerlongfloatzfloating-pointcomplexcCsYt|j\}}y||SWn1tk
rTttd|||fYnXdS)Nzoption %s: invalid %s value: %r)_builtin_cvtrr5rr()r%rpvalueZcvtZwhatrrr
check_builtins
rcCsQ||jkr|Sdjtt|j}ttd|||fdS)Nz, z.option %s: invalid choice: %r (choose from %s))choicesr+mapreprrr()r%rprrrrrcheck_choices	rZNOZDEFAULTc@seZdZdZdddddddd	d
ddd
gZdAZdBZdCZdDZdEZ	dFZ
dededededeiZ
dZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2ZeeeeeeegZd3d4ZeZd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dS)Grar
    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
    actionrr^defaultnargsconstrcallback
callback_argscallback_kwargsr[rsstorestore_const
store_truestore_falserhappend_constcountversionstringr1rrrchoiceNcOs]g|_g|_|j|}|j||j|x|jD]}||qEWdS)N)rvrw_check_opt_strings_set_opt_strings
_set_attrs
CHECK_METHODS)rrkattrscheckerrrrr3s		

zOption.__init__cCs)dd|D}|s%td|S)NcSsg|]}|r|qSrr)rcrprrrreJs	z-Option._check_opt_strings.<locals>.<listcomp>z+at least one option string must be supplied)	TypeError)rrkrrrrFszOption._check_opt_stringscCsx|D]}t|dkr5td||qt|dkr|ddkod|ddksztd|||jj|q|dddko|ddkstd|||jj|qWdS)	Nr-z>invalid option string %r: must be at least two characters longr-rzMinvalid short option string %r: must be of the form -x, (x any non-dash char)z--zGinvalid long option string %r: must start with --, followed by non-dash)rgr
rvrhrw)rrkrprrrrOs$
 	&	zOption._set_opt_stringscCsxj|jD]_}||kr:t||||||=q
|dkrYt||tq
t||dq
W|rt|j}tddj||dS)Nrzinvalid keyword arguments: %sz, )ATTRSsetattrr_sortedkeysr
r+)rrattrrrrrds
zOption._set_attrscCsG|jdkrd|_n(|j|jkrCtd|j|dS)Nrzinvalid action: %r)rACTIONSr
)rrrr
_check_actionwszOption._check_actioncCs|jdkrH|j|jkr|jdk	r<d|_qd|_nt|jtri|jj|_|jdkrd|_|j|jkrtd|j||j|jkrtd|j|dS)Nrrr#zinvalid option type: %rz$must not supply a type for action %r)	rrALWAYS_TYPED_ACTIONSr
isinstancerTYPESr

TYPED_ACTIONS)rrrr_check_type}s	zOption._check_typecCs|jdkrz|jdkr0td|qt|jttfstdtt|jjdd|n%|jdk	rtd|j|dS)Nrz/must supply a list of choices for type 'choice'z1choices must be a list of strings ('%s' supplied)'rz#must not supply choices for type %r)rrr
rtuplelistr#split)rrrr
_check_choices,zOption._check_choicecCs|j|jkp|jdk	}|jdkr||r||jrh|jdddjdd|_n|jdd|_dS)Nrr-rr(r)r
STORE_ACTIONSrr^rwrarv)rrtrrr_check_dests	)zOption._check_destcCs;|j|jkr7|jdk	r7td|j|dS)Nz*'const' must not be supplied for action %r)r
CONST_ACTIONSrr
)rrrr_check_consts!
zOption._check_constcCsV|j|jkr-|jdkrRd|_n%|jdk	rRtd|j|dS)Nrz*'nargs' must not be supplied for action %r)rrrr
)rrrr_check_nargss
zOption._check_nargscCs|jdkrt|js4td|j||jdk	rlt|jtrltd|j||jdk	rt|jtrtd|j|na|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
rrrrdict)rrrr_check_callbacks0zOption._check_callbackcCsdj|j|jS)N/)r+rvrw)rrrrr szOption.__str__cCs
|jdk	S)N)r)rrrrrtszOption.takes_valuecCs#|jr|jdS|jdSdS)Nr)rwrv)rrrrget_opt_strings	zOption.get_opt_stringcCs9|jj|j}|dkr%|S||||SdS)N)TYPE_CHECKERr]r)rrprrrrrcheck_valueszOption.check_valuecsO|dk	rKjdkr+j|Stfdd|DSdS)Nrcs"g|]}j|qSr)r)rcv)rprrrres	z(Option.convert_value.<locals>.<listcomp>)rrr)rrprr)rprr
convert_valueszOption.convert_valuecCs4|j||}|j|j|j||||S)N)rtake_actionrr^)rrprvaluesr/rrrprocessszOption.processc	Cs|dkrt|||n|dkrAt|||jnb|dkr`t||dnC|dkrt||dn$|dkr|j|gj|n|dkr|j|gj|jn|d	krt|||j|d
dn|dkrJ|jpf}|jp(i}|j||||||nY|d
krm|j|jn6|dkr|j	|jnt
d|jdS)NrrrTrFrhrrrrrr[rzunknown action %r)rrensure_valuerhrrr
print_helpexit
print_versionr5r)	rrr^rprrr/argskwargsrrrrs4#



zOption.take_action)
rrrrrhrrrr[r)rrrrrhrr)rrhr)rrh)rr)rr1rrrr)#rr!r"r&rrrrrrrrrrrrrrrrrrrrrrr r__repr__rtrrrrrrrrrrs		
			ZSUPPRESSZHELPZUSAGEc@seZdZdddZddZeZddZdd	Zd
dZ	dd
Z
dddZdddZddZ
dS)rNcCs7|r3x*|jD]\}}t|||qWdS)N)itemsr)rr\rr~rrrr8szValues.__init__cCs
t|jS)N)r#__dict__)rrrrr =szValues.__str__cCsCt|tr|j|jkSt|tr;|j|kStSdS)N)rrrrNotImplemented)rotherrrr__eq__Bs

z
Values.__eq__cCsMxFt|D]8}||kr
||}|dk	r
t|||q
WdS)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_carefulJs

zValues._update_carefulcCs|jj|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_looseWszValues._update_loosecCsL|dkr|j|n,|dkr8|j|ntd|dS)NcarefulZloosezinvalid update mode: %r)rrr5)rrmoderrr_update_s
zValues._updatercCs1t|tj|}|jt||dS)N)
__import__sysmodulesrvars)rmodnamermodrrrread_modulegs

zValues.read_modulecCs3i}tt|j||j||dS)N)execopenreadr)rfilenamerrrrr	read_filelszValues.read_filecCsBt||s%t||dkr5t|||t||S)N)hasattrgetattrr)rrrrrrrqs%zValues.ensure_value)rr!r"rr rrrrrrrrrrrrrr6s
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.

    cCs1|j||_|j||j|dS)N)_create_option_listoption_classset_conflict_handlerset_description)rrconflict_handlerrWrrrrs
	
zOptionContainer.__init__cCsi|_i|_i|_dS)N)
_short_opt	_long_optr\)rrrr_create_option_mappingss		z'OptionContainer._create_option_mappingscCs(|j|_|j|_|j|_dS)N)rrr\)rr/rrr_share_option_mappingssz&OptionContainer._share_option_mappingscCs)|dkrtd|||_dS)Nerrorresolvez$invalid conflict_resolution value %r)rr)r5r)rhandlerrrrrsz$OptionContainer.set_conflict_handlercCs
||_dS)N)rW)rrWrrrrszOptionContainer.set_descriptioncCs|jS)N)rW)rrrrget_descriptionszOptionContainer.get_descriptioncCs|`|`|`dS)zsee OptionParser.destroy().N)rrr\)rrrrdestroyszOptionContainer.destroycCsYg}x:|jD]/}||jkr|j||j|fqWx:|jD]/}||jkrM|j||j|fqMW|rU|j}|dkrtddjdd|D|n|dkrUx|D]w\}}|jdr|jj	||j|=n|jj	||j|=|jp;|js|j
jj	|qWdS)Nrz conflicting option string(s): %sz, cSsg|]}|dqS)rr)rccorrrres	z3OptionContainer._check_conflict.<locals>.<listcomp>rz--)rvrrhrwrrrr+
startswithremove	containerrm)rr%Z
conflict_optsrprZc_optionrrr_check_conflicts.	

zOptionContainer._check_conflictcOs;t|dtr(|j||}nQt|dkrm|rm|d}t|tsytd|ntd|j||jj|||_	x|j
D]}||j|<qWx|jD]}||j
|<qW|jdk	r7|jtk	r|j|j|j<n"|j|jkr7d|j|j<|S)zOadd_option(Option)
           add_option(opt_str, ..., kwarg=val, ...)
        rrznot an Option instance: %rzinvalid argumentsN)rr#rrgrrrrmrhrrvrrwrr^rr_r\)rrrr%rprrr
add_options(

	zOptionContainer.add_optioncCs"x|D]}|j|qWdS)N)r)rrmr%rrradd_optionss
zOptionContainer.add_optionscCs"|jj|p!|jj|S)N)rr]r)rr'rrr
get_optionszOptionContainer.get_optioncCs||jkp||jkS)N)rr)rr'rrr
has_option
szOptionContainer.has_optioncCs|jj|}|dkr0|jj|}|dkrLtd|x|jD]}|j|=qVWx|jD]}|j|=qtW|jjj|dS)Nzno such option %r)	rr]rr5rvrwrrmr)rr'r%rprrr
remove_optionszOptionContainer.remove_optioncCsY|js
dSg}x6|jD]+}|jtk	r|j|j|qWdj|S)NrD)rmr[rrhrlr+)r	formatterrjr%rrrformat_option_helps	z"OptionContainer.format_option_helpcCs|j|jS)N)rXr)rrrrrrX'sz"OptionContainer.format_descriptioncCsQg}|jr%|j|j||jrD|j|j|dj|S)NrV)rWrhrXrmrr+)rrrjrrrformat_help*s		zOptionContainer.format_helpN)rr!r"r&rrrrrrrrrrrrrrrXrrrrrrws"			c@sOeZdZdddZddZddZdd	Zd
dZdS)rNcCs2||_tj||j|j|||_dS)N)r/rrrrtitle)rr/rrWrrrr5s	zOptionGroup.__init__cCsg|_|j|jdS)N)rmrr/)rrrrr;s	zOptionGroup._create_option_listcCs
||_dS)N)r)rrrrr	set_title?szOptionGroup.set_titlecCstj||`dS)zsee OptionParser.destroy().N)rrrm)rrrrrBs
zOptionGroup.destroycCs@|j|j}|j|tj||7}|j|S)N)rQrrJrrrL)rrrjrrrrIs


zOptionGroup.format_help)rr!r"rrrrrrrrrr3s
c@seZdZdZgZddeddddddddd
ZddZd	d
ZddZ	d
dZ
dddZddZddZ
ddZddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zddd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Z d;dd<d=Z!d>d?Z"d@dAZ#ddBdCZ$dDdEZ%ddFdGZ&ddHdIZ'dJdKZ(ddLdMZ)ddNdOZ*dS)Pra$
    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.

    NrTcCstj|||||j||	|_||_d|_d|_|dkr\t}||_|jj	||
|_
|j|d||jdS)NTadd_help)
rr	set_usageprograllow_interspersed_argsprocess_default_valuesr
rrCrY_populate_option_list_init_parsing_state)rrNrmrrrrWrZadd_help_optionrrYrrrrs
							zOptionParser.__init__cCsAtj|x|jD]}|jqW|`|`|`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)rrrormr)rrqrrrrs
zOptionParser.destroycCs g|_g|_|jdS)N)rmror)rrrrrs		z OptionParser._create_option_listcCs&|jdddddtddS)Nz-hz--helprr[zshow this help message and exit)rr()rrrr_add_help_optionszOptionParser._add_help_optioncCs#|jddddtddS)Nz	--versionrrr[z&show program's version number and exit)rr()rrrr_add_version_optionsz OptionParser._add_version_optioncCsS|jr|j|j|r,|j||jr?|j|rO|jdS)N)standard_option_listrrr
r)rrmrrrrr
s	
	
z"OptionParser._populate_option_listcCsd|_d|_d|_dS)N)rargslargsr)rrrrrs		z OptionParser._init_parsing_statecCsn|dkrtd|_nL|tkr6d|_n4|jjdra|dd|_n	||_dS)Nz%prog [options]zusage: )r(rNrr}r)rrNrrrrs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.TN)r)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.
        FN)r)rrrrdisable_interspersed_argssz&OptionParser.disable_interspersed_argscCs
||_dS)N)r	)rrrrrset_process_default_values
sz'OptionParser.set_process_default_valuescCs||j|<dS)N)r\)rr^rrrrset_default
szOptionParser.set_defaultcKs|jj|dS)N)r\r)rrrrrset_defaultsszOptionParser.set_defaultscCs;|jdd}x!|jD]}|j|jqW|S)N)rmrori)rZoptionsrqrrr_get_all_optionsszOptionParser._get_all_optionscCs|jst|jS|jj}xZ|jD]L}|j|j}t|tr2|j	}|j
||||j<q2Wt|S)N)r	rr\copyrr]r^rr#rr)rr\r%rr'rrrget_default_valuess	
zOptionParser.get_default_valuescOst|dtr(t|||}nlt|dkr|r|d}t|tsjtd||j|k	rtdntd|jj||S)Nrrznot an OptionGroup instance: %rz"invalid OptionGroup (wrong parser)zinvalid arguments)	rr#rrgrr/r5rorh)rrrrqrrradd_option_group*s
zOptionParser.add_option_groupcCsD|jj|p!|jj|}|r@|j|k	r@|jSdS)N)rr]rr)rr'r%rrrget_option_group:s
zOptionParser.get_option_groupcCs/|dkrtjddS|ddSdS)Nr)rargv)rrrrr	_get_argsDszOptionParser._get_argscCs|j|}|dkr'|j}||_g|_}||_y|j|||}Wn>ttfk
r}z|jt	|WYdd}~XnX||}|j
||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)rrrrr
_process_argsrrrr#check_values)rrrrrstoperrrrr
parse_argsJs	
	&
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)rrrrrrrqszOptionParser.check_valuescCsx|r|d}|dkr*|d=dS|dddkrS|j||q|dddkrt|dkr|j||q|jr|j||d=qdSqWdS)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'.
        rz--Nr-rr)_process_long_optrg_process_short_optsrrh)rrrrargrrrr~s
	
(	

zOptionParser._process_argscCst||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)rrprrr_match_long_optszOptionParser._match_long_optc
CsK|jd}d|krL|jdd\}}|jd|d}n|}d}|j|}|j|}|jr|j}t||kr|jt	dd|d|d	|iq1|dkr|jd}	q1t
|d|}	|d|=n&|r+|jtd
|nd}	|j||	||dS)NrrHrTFz.%(option)s option requires %(number)d argumentz/%(option)s option requires %(number)d argumentsr%numberz%s option does not take a value)
poprinsertr'rrtrrgrrrr(r)
rrrr%rpZnext_argZhad_explicit_valuer%rrrrrr#s0	
		zOptionParser._process_long_optcCs^|jd}d}d}x<|ddD]*}d|}|jj|}|d7}|sjt||jr3|t|kr|jd||dd}|j}	t||	kr|jt	dd|	d|d	|	iq9|	dkr
|jd}
q9t
|d|	}
|d|	=nd}
|j||
|||r,Pq,WdS)
NrFrrTz.%(option)s option requires %(number)d argumentz/%(option)s option requires %(number)d argumentsr%r()r)rr]rrtrgr*rrrrr)rrrr%r iZchrpr%rrrrrr$s6

		z OptionParser._process_short_optscCs1|jdkr&tjjtjdS|jSdS)Nr)rr2pathbasenamerr)rrrr
get_prog_nameszOptionParser.get_prog_namecCs|jd|jS)Nz%prog)rar.)rsrrrexpand_prog_name
szOptionParser.expand_prog_namecCs|j|jS)N)r0rW)rrrrrszOptionParser.get_descriptionrcCs'|rtjj|tj|dS)N)rstderrwriter)rZstatusrrrrrszOptionParser.exitcCs4|jtj|jdd|j|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.
        r-z%s: error: %s
N)print_usagerr1rr.)rrrrrrszOptionParser.errorcCs-|jr%|jj|j|jSdSdS)NrD)rNrrOr0)rrrr	get_usage"s		zOptionParser.get_usagecCs#|jrt|jd|dS)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)rNprintr4)rr5rrrr3)s		zOptionParser.print_usagecCs!|jr|j|jSdSdS)NrD)rr0)rrrrget_version5s	zOptionParser.get_versioncCs#|jrt|jd|dS)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.
        r5N)rr6r7)rr5rrrr;s	zOptionParser.print_versioncCs|dkr|j}|j|g}|j|jtd|j|jr}|jtj|||jdx4|j	D])}|j|j
||jdqW|jdj|ddS)NZOptionsrVrDrrf)
rrrrhrQr(rJrmrrrorrLr+)rrrjrqrrrrFs	

	

zOptionParser.format_option_helpcCs|j|jS)N)rZrY)rrrrrrZWszOptionParser.format_epilogcCs|dkr|j}g}|jr;|j|jd|jr^|j|j|d|j|j||j|j|dj|S)NrVrD)	rrNrhr4rWrXrrZr+)rrrjrrrrZs			zOptionParser.format_helpcCs,|dkrtj}|j|jdS)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)rstdoutr2r)rr5rrrrfs	zOptionParser.print_help)+rr!r"r&rrrrrrr
r
rrrrrrrrrrrrr"rrr'r#r$r.r0rrrr4r3r7rrrZrrrrrrrQs`D
	
'
3	$)
cs{|krSfdd|jD}t|dkrI|dS|s^tn|jt|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.
    cs%g|]}|jr|qSr)r)rcZword)r/rrres	z!_match_abbrev.<locals>.<listcomp>rrN)rrgrsortr))r/Zwordmapr*r)r/rr&ss
r&)'r&__version____all__Z
__copyright__rr2rSrrrImportErrorr(	Exceptionrr
rrrr)r	r
rrrrrrrrr_rrrrrrrr&rrrrr<module>sr	 




t

A$