%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/__pycache__/argparse.cpython-38.pyc

U

naw@s0dZdZdddddddd	d
ddd
dddddgZddlZddlZddlZddl	Z
ddlmZm
Z
dZdZdZdZdZdZdZGdddeZdd ZGd!ddeZGd"ddeZGd#d	d	eZGd$ddeZGd%d
d
eZd&d'ZGd(ddeZGd)ddeZ Gd*ddeZ!Gd+d,d,e!Z"Gd-d.d.e!Z#Gd/d0d0e#Z$Gd1d2d2e#Z%Gd3d4d4e!Z&Gd5d6d6e!Z'Gd7d8d8e!Z(Gd9d:d:e!Z)Gd;d<d<e!Z*Gd=d>d>e!Z+Gd?d@d@e&Z,GdAddeZ-GdBddeZ.GdCdDdDeZ/GdEdFdFe/Z0GdGdHdHe0Z1GdIddee/Z2dS)Ja
Command-line parsing library

This module is an optparse-inspired command-line parsing library that:

    - handles both optional and positional arguments
    - produces highly informative usage messages
    - supports parsers that dispatch to sub-parsers

The following is a simple usage example that sums integers from the
command-line and writes the result to a file::

    parser = argparse.ArgumentParser(
        description='sum the integers at the command line')
    parser.add_argument(
        'integers', metavar='int', nargs='+', type=int,
        help='an integer to be summed')
    parser.add_argument(
        '--log', default=sys.stdout, type=argparse.FileType('w'),
        help='the file where the sum should be written')
    args = parser.parse_args()
    args.log.write('%s' % sum(args.integers))
    args.log.close()

The module contains the following public classes:

    - ArgumentParser -- The main entry point for command-line parsing. As the
        example above shows, the add_argument() method is used to populate
        the parser with actions for optional and positional arguments. Then
        the parse_args() method is invoked to convert the args at the
        command-line into an object with attributes.

    - ArgumentError -- The exception raised by ArgumentParser objects when
        there are errors with the parser's actions. Errors raised while
        parsing the command-line are caught by ArgumentParser and emitted
        as command-line messages.

    - FileType -- A factory for defining types of files to be created. As the
        example above shows, instances of FileType are typically passed as
        the type= argument of add_argument() calls.

    - Action -- The base class for parser actions. Typically actions are
        selected by passing strings like 'store_true' or 'append_const' to
        the action= argument of add_argument(). However, for greater
        customization of ArgumentParser actions, subclasses of Action may
        be defined and passed as the action= argument.

    - HelpFormatter, RawDescriptionHelpFormatter, RawTextHelpFormatter,
        ArgumentDefaultsHelpFormatter -- Formatter classes which
        may be passed as the formatter_class= argument to the
        ArgumentParser constructor. HelpFormatter is the default,
        RawDescriptionHelpFormatter and RawTextHelpFormatter tell the parser
        not to change the formatting for help text, and
        ArgumentDefaultsHelpFormatter adds information about argument defaults
        to the help.

All other classes in this module are considered implementation details.
(Also note that HelpFormatter and RawDescriptionHelpFormatter are only
considered public as object names -- the API of the formatter objects is
still considered an implementation detail.)
z1.1ArgumentParser
ArgumentErrorArgumentTypeErrorFileType
HelpFormatterArgumentDefaultsHelpFormatterRawDescriptionHelpFormatterRawTextHelpFormatterMetavarTypeHelpFormatter	NamespaceActionONE_OR_MOREOPTIONALPARSER	REMAINDERSUPPRESSZERO_OR_MOREN)gettextngettextz==SUPPRESS==?*+zA......_unrecognized_argsc@s(eZdZdZddZddZddZdS)	_AttributeHolderaAbstract base class that provides __repr__.

    The __repr__ method returns a string in the format::
        ClassName(attr=name, attr=name, ...)
    The attributes are determined either by a class-level attribute,
    '_kwarg_names', or by inspecting the instance __dict__.
    cCst|j}g}i}|D]}|t|q|D],\}}|rZ|d||fq6|||<q6|rz|dt|d|d|fS)N%s=%rz**%s%s(%s), )type__name__	_get_argsappendrepr_get_kwargsisidentifierjoin)self	type_namearg_strings	star_argsargnamevaluer-$/usr/local/lib/python3.8/argparse.py__repr__ts

z_AttributeHolder.__repr__cCst|jSN)sorted__dict__itemsr&r-r-r.r#sz_AttributeHolder._get_kwargscCsgSr0r-r4r-r-r.r sz_AttributeHolder._get_argsN)r
__module____qualname____doc__r/r#r r-r-r-r.rksrcCs6|dkrgSt|tkr$|ddSddl}||S)Nr)rlistcopy)r3r9r-r-r._copy_itemssr:c@seZdZdZd;ddZddZd	d
ZGdddeZd
dZ	ddZ
ddZddZd<ddZ
ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:ZdS)=rzFormatter for generating usage messages and argument help strings.

    Only the name of this class is considered a public API. All the methods
    provided by the class are considered an implementation detail.
    NcCs|dkrtj}|d8}||_||_t|t|d|d|_||_d|_	d|_
d|_||d|_
|j
|_tdtj|_td|_dS)Nr;rz\s+z\n\n\n+)_shutilget_terminal_sizecolumns_prog_indent_incrementminmax_max_help_position_width_current_indent_level_action_max_length_Section
_root_section_current_section_recompileASCII_whitespace_matcher_long_break_matcher)r&progindent_incrementmax_help_positionwidthr-r-r.__init__s 
zHelpFormatter.__init__cCs"|j|j7_|jd7_dSN)rGrBrHr4r-r-r._indentszHelpFormatter._indentcCs4|j|j8_|jdks"td|jd8_dS)NrzIndent decreased below 0.rX)rGrBAssertionErrorrHr4r-r-r._dedentszHelpFormatter._dedentc@seZdZdddZddZdS)zHelpFormatter._SectionNcCs||_||_||_g|_dSr0)	formatterparentheadingr3)r&r\r]r^r-r-r.rVszHelpFormatter._Section.__init__cCs|jdk	r|j|jj}|dd|jD}|jdk	rD|j|sLdS|jtk	rz|jdk	rz|jj}d|d|jf}nd}|d||dgS)NcSsg|]\}}||qSr-r-).0funcargsr-r-r.
<listcomp>sz6HelpFormatter._Section.format_help.<locals>.<listcomp>z%*s%s:

)	r]r\rY_join_partsr3r[r^rrG)r&r%	item_helpcurrent_indentr^r-r-r.format_helps



z"HelpFormatter._Section.format_help)N)rr5r6rVrhr-r-r-r.rJs
rJcCs|jj||fdSr0)rLr3r!)r&r`rar-r-r.	_add_itemszHelpFormatter._add_itemcCs0||||j|}||jg||_dSr0)rYrJrLrirh)r&r^sectionr-r-r.
start_sectionszHelpFormatter.start_sectioncCs|jj|_|dSr0)rLr]r[r4r-r-r.end_sections
zHelpFormatter.end_sectioncCs$|tk	r |dk	r ||j|gdSr0)rri_format_text)r&textr-r-r.add_textszHelpFormatter.add_textcCs&|tk	r"||||f}||j|dSr0)rri
_format_usage)r&usageactionsgroupsprefixrar-r-r.	add_usageszHelpFormatter.add_usagecCsv|jtk	rr|j}||g}||D]}|||q$tdd|D}||j}t|j||_||j	|gdS)NcSsg|]}t|qSr-lenr_sr-r-r.rb
sz.HelpFormatter.add_argument.<locals>.<listcomp>)
helpr_format_action_invocation_iter_indented_subactionsr!rDrGrIri_format_action)r&actionget_invocationinvocations	subactioninvocation_length
action_lengthr-r-r.add_arguments


zHelpFormatter.add_argumentcCs|D]}||qdSr0)r)r&rrr~r-r-r.
add_argumentsszHelpFormatter.add_argumentscCs.|j}|r*|jd|}|dd}|S)N

rd)rKrhrQsubstrip)r&rzr-r-r.rhs

zHelpFormatter.format_helpcCsddd|DS)NrccSsg|]}|r|tk	r|qSr-)r)r_partr-r-r.rb!sz-HelpFormatter._join_parts.<locals>.<listcomp>)r%)r&part_stringsr-r-r.re s
zHelpFormatter._join_partscs6|dkrtd}|dk	r,|t|jd}n|dkrL|sLdt|jd}n|dkr*dt|jd}g}g}|D] }|jr||qr||qr|j}	|	|||}
ddd||
fD}|j|jt	|t	|kr*d}|	||}|	||}
t
||}t
||
}d||ks&td||
ks:tdfdd		}t	|t	|d
krdt	|t	|d}|r||g|||}|
|||n |r||g|||}n|g}nZdt	|}||}|||}t	|dkrg}|
||||
||||g|}d|}d
||fS)Nzusage: rRz%(prog)s cSsg|]}|r|qSr-r-rxr-r-r.rbAsz/HelpFormatter._format_usage.<locals>.<listcomp>z%\(.*?\)+(?=\s|$)|\[.*?\]+(?=\s|$)|\S+csg}g}|dk	rt|d}nt|d}|D]Z}|dt|krn|rn||d|g}t|d}|||t|d7}q.|r||d||dk	r|dt|d|d<|S)NrXrr)rwr!r%)partsindentrtlineslineline_lenr
text_widthr-r.	get_linesUs"
z.HelpFormatter._format_usage.<locals>.get_linesg?rXrdz%s%s

)N)_dictrAoption_stringsr!_format_actions_usager%rFrGrwrMfindallrZextend)r&rqrrrsrtrR	optionalspositionalsr~formataction_usagepart_regexp	opt_usage	pos_usage	opt_parts	pos_partsrrrrr-rr.rp%s\





zHelpFormatter._format_usagec	Cst}i}|D]}z||jd}Wntk
r@YqYqX|t|j}||||jkr|jD]}||qh|js||kr||d7<nd||<||kr||d7<nd||<nF||kr||d7<nd||<||kr||d7<nd||<t|d|D]}	d	||	<qqg}
t|D]"\}	}|j	t
kr|
d||	d	krr|
|	n"||	dd	krX|
|	dn|js||}|||}||kr|ddkr|d
dkr|dd
}|
|nf|jd}
|jdkrd|
}n"||}|||}d|
|f}|jsN||krNd
|}|
|q6t|ddD]}	||	g|
|	|	<qhddd|
D}d}d}td|d|}td|d|}td||fd|}tdd|}|}|S)Nrz [[]z (()rX|%s%s %s[%s]T)reversercSsg|]}|dk	r|qSr0r-)r_itemr-r-r.rbsz7HelpFormatter._format_actions_usage.<locals>.<listcomp>z[\[(]z[\])]z(%s) z\1 (%s)z%s *%srcz\(([^|]*)\))setindex_group_actions
ValueErrorrwaddrequiredrange	enumeraterzrr!getpopr#_get_default_metavar_for_positional_format_argsnargs!_get_default_metavar_for_optionalr1r%rMrr)r&rrrs
group_actionsinsertsgroupstartendr~irdefaultr
option_stringargs_stringrnopencloser-r-r.rsz










z#HelpFormatter._format_actions_usagecCsFd|kr|t|jd}t|j|jd}d|j}||||dS)Nz%(prog)rrr)rrArDrFrG
_fill_text)r&rnrrr-r-r.rms

zHelpFormatter._format_textc
Cs:t|jd|j}t|j|d}||jd}||}|jsV|jd|f}d|}n@t||kr~|jd||f}d|}d}n|jd|f}d|}|}|g}|jr|	|}	|
|	|}
|d|d|
df|
ddD]}|d|d|fqn|ds|d|
|D]}|||q||S)	Nr;rrcz%*s%s
z	%*s%-*s  rrXrd)rCrIrErDrFrGr{rzrw_expand_help_split_linesr!endswithr|r}re)
r&r~
help_position
help_widthaction_width
action_headertupindent_firstr	help_text
help_linesrrr-r-r.r}s8




zHelpFormatter._format_actioncCs|js&||}|||d\}|Sg}|jdkrB||jn4||}|||}|jD]}|d||fq^d|SdS)NrXrrr)	rr_metavar_formatterrrrrr!r%)r&r~rmetavarrrrr-r-r.r{"s



z'HelpFormatter._format_action_invocationcsP|jdk	r|jn.|jdk	r<dd|jD}dd|n|fdd}|S)NcSsg|]}t|qSr-str)r_choicer-r-r.rb>sz4HelpFormatter._metavar_formatter.<locals>.<listcomp>z{%s},csttrSf|SdSr0)
isinstancetuple)
tuple_sizeresultr-r.rCs
z0HelpFormatter._metavar_formatter.<locals>.format)rchoicesr%)r&r~default_metavarchoice_strsrr-rr.r:s

z HelpFormatter._metavar_formattercCs|||}|jdkr$d|d}n|jtkr<d|d}n|jtkrTd|d}n|jtkrld|d}n|jtkr|d}nt|jtkrd|d}n\|jtkrd	}nLzd
dt|jD}Wnt	k
rt
ddYnXd
|||j}|S)NrrXrz
[%s [%s ...]]r;z%s [%s ...]rz%s ...rccSsg|]}dqS)rr-)r_rr-r-r.rb\sz.HelpFormatter._format_args.<locals>.<listcomp>zinvalid nargs valuer)rrr
rrrrrr	TypeErrorrr%)r&r~rget_metavarrformatsr-r-r.rJs*






zHelpFormatter._format_argscCstt||jd}t|D]}||tkr||=qt|D] }t||dr:||j||<q:|ddk	rddd|dD}||d<|	||S)NrrrrcSsg|]}t|qSr-r)r_cr-r-r.rbksz.HelpFormatter._expand_help.<locals>.<listcomp>)
rvarsrAr8rhasattrrrr%_get_help_string)r&r~paramsr+choices_strr-r-r.rbszHelpFormatter._expand_helpccs@z
|j}Wntk
rYnX||EdH|dSr0)_get_subactionsAttributeErrorrYr[)r&r~get_subactionsr-r-r.r|os
z'HelpFormatter._iter_indented_subactionscCs&|jd|}ddl}|||S)Nrr)rPrrtextwrapwrap)r&rnrUrr-r-r.ryszHelpFormatter._split_linescCs,|jd|}ddl}|j||||dS)Nrr)initial_indentsubsequent_indent)rPrrrfill)r&rnrUrrr-r-r.rszHelpFormatter._fill_textcCs|jSr0)rzr&r~r-r-r.rszHelpFormatter._get_help_stringcCs
|jSr0)destupperrr-r-r.rsz/HelpFormatter._get_default_metavar_for_optionalcCs|jSr0)rrr-r-r.rsz1HelpFormatter._get_default_metavar_for_positional)r;r<N)N) rr5r6r7rVrYr[objectrJrirkrlrorurrrhrerprrmr}r{rrrr|rrrrrr-r-r-r.rs>

`g/

c@seZdZdZddZdS)rzHelp message formatter which retains any formatting in descriptions.

    Only the name of this class is considered a public API. All the methods
    provided by the class are considered an implementation detail.
    cs dfdd|jddDS)Nrcc3s|]}|VqdSr0r-)r_rrr-r.	<genexpr>sz9RawDescriptionHelpFormatter._fill_text.<locals>.<genexpr>T)keepends)r%
splitlines)r&rnrUrr-rr.rsz&RawDescriptionHelpFormatter._fill_textN)rr5r6r7rr-r-r-r.rsc@seZdZdZddZdS)rzHelp message formatter which retains formatting of all help text.

    Only the name of this class is considered a public API. All the methods
    provided by the class are considered an implementation detail.
    cCs|Sr0)r)r&rnrUr-r-r.rsz!RawTextHelpFormatter._split_linesN)rr5r6r7rr-r-r-r.rsc@seZdZdZddZdS)rzHelp message formatter which adds default values to argument help.

    Only the name of this class is considered a public API. All the methods
    provided by the class are considered an implementation detail.
    cCs>|j}d|jkr:|jtk	r:ttg}|js2|j|kr:|d7}|S)Nz
%(default)z (default: %(default)s))rzrrr
rrr)r&r~rzdefaulting_nargsr-r-r.rs

z.ArgumentDefaultsHelpFormatter._get_help_stringN)rr5r6r7rr-r-r-r.rsc@s eZdZdZddZddZdS)r	aHelp message formatter which uses the argument 'type' as the default
    metavar value (instead of the argument 'dest')

    Only the name of this class is considered a public API. All the methods
    provided by the class are considered an implementation detail.
    cCs|jjSr0rrrr-r-r.rsz:MetavarTypeHelpFormatter._get_default_metavar_for_optionalcCs|jjSr0rrr-r-r.rsz<MetavarTypeHelpFormatter._get_default_metavar_for_positionalN)rr5r6r7rrr-r-r-r.r	scCsN|dkrdS|jrd|jS|jdtfkr2|jS|jdtfkrF|jSdSdS)N/)rr%rrr)argumentr-r-r._get_action_namesrc@s eZdZdZddZddZdS)rzAn error from creating or using an argument (optional or positional).

    The string value of this exception is the message, augmented with
    information about the argument that caused it.
    cCst||_||_dSr0)r
argument_namemessage)r&rrr-r-r.rVs
zArgumentError.__init__cCs(|jdkrd}nd}|t|j|jdS)Nz%(message)sz'argument %(argument_name)s: %(message)s)rr)rrr)r&rr-r-r.__str__s
zArgumentError.__str__N)rr5r6r7rVrr-r-r-r.rsc@seZdZdZdS)rz@An error from trying to convert a command line string to a type.N)rr5r6r7r-r-r-r.rsc@s,eZdZdZd
ddZddZddd	ZdS)ra\	Information about how to convert command line strings to Python objects.

    Action objects are used by an ArgumentParser to represent the information
    needed to parse a single argument from one or more strings from the
    command line. The keyword arguments to the Action constructor are also
    all attributes of Action instances.

    Keyword Arguments:

        - option_strings -- A list of command-line option strings which
            should be associated with this action.

        - dest -- The name of the attribute to hold the created object(s)

        - nargs -- The number of command-line arguments that should be
            consumed. By default, one argument will be consumed and a single
            value will be produced.  Other values include:
                - N (an integer) consumes N arguments (and produces a list)
                - '?' consumes zero or one arguments
                - '*' consumes zero or more arguments (and produces a list)
                - '+' consumes one or more arguments (and produces a list)
            Note that the difference between the default and nargs=1 is that
            with the default, a single value will be produced, while with
            nargs=1, a list containing a single value will be produced.

        - const -- The value to be produced if the option is specified and the
            option uses an action that takes no values.

        - default -- The value to be produced if the option is not specified.

        - type -- A callable that accepts a single string argument, and
            returns the converted value.  The standard Python types str, int,
            float, and complex are useful examples of such callables.  If None,
            str is used.

        - choices -- A container of values that should be allowed. If not None,
            after a command-line argument has been converted to the appropriate
            type, an exception will be raised if it is not a member of this
            collection.

        - required -- True if the action must always be specified at the
            command line. This is only meaningful for optional command-line
            arguments.

        - help -- The help string describing the argument.

        - metavar -- The name to be used for the option's argument with the
            help string. If None, the 'dest' value will be used as the name.
    NFcCs@||_||_||_||_||_||_||_||_|	|_|
|_	dSr0
rrrconstrrrrrzrr&rrrrrrrrrzrr-r-r.rV)szAction.__init__c	s(ddddddddd	g	}fd
d|DS)Nrrrrrrrrzrcsg|]}|t|fqSr-getattrr_r+r4r-r.rbKsz&Action._get_kwargs.<locals>.<listcomp>r-r&namesr-r4r.r#?szAction._get_kwargscCsttddS)Nz.__call__() not defined)NotImplementedErrorrr&parser	namespacevaluesrr-r-r.__call__MszAction.__call__)NNNNNFNN)N)rr5r6r7rVr#rr-r-r-r.rs5
cs(eZdZdfdd	ZdddZZS)	_StoreActionNFcsT|dkrtd|dk	r,|tkr,tdttt|j|||||||||	|
d
dS)Nrznargs for store actions must be != 0; if you have nothing to store, actions such as store true or store const may be more appropriate nargs must be %r to supply constr)rr
superrrVr	__class__r-r.rVSs 
z_StoreAction.__init__cCst||j|dSr0)setattrrrr-r-r.rpsz_StoreAction.__call__)NNNNNFNN)Nrr5r6rVr
__classcell__r-r-rr.rQsrcs(eZdZdfdd	ZdddZZS)	_StoreConstActionNFc	s"tt|j||d||||ddS)Nr)rrrrrrrz)rrrVr&rrrrrrzrrr-r.rVvs
z_StoreConstAction.__init__cCst||j|jdSr0)rrrrr-r-r.rsz_StoreConstAction.__call__)NFNN)Nrr-r-rr.rtsrcseZdZdfdd	ZZS)_StoreTrueActionFNcs tt|j||d|||ddS)NTrrrrrrz)rrrVr&rrrrrzrr-r.rVs
z_StoreTrueAction.__init__)FFNrr5r6rVrr-r-rr.rsrcseZdZdfdd	ZZS)_StoreFalseActionTFNcs tt|j||d|||ddS)NFr)rr!rVrrr-r.rVs
z_StoreFalseAction.__init__)TFNr r-r-rr.r!sr!cs(eZdZdfdd	ZdddZZS)	
_AppendActionNFcsT|dkrtd|dk	r,|tkr,tdttt|j|||||||||	|
d
dS)Nrznargs for append actions must be != 0; if arg strings are not supplying the value to append, the append const action may be more appropriaterr)rr
rr"rVrrr-r.rVs 
z_AppendAction.__init__cCs2t||jd}t|}||t||j|dSr0)r	rr:r!rr&rrrrr3r-r-r.rs
z_AppendAction.__call__)NNNNNFNN)Nrr-r-rr.r"sr"cs(eZdZdfdd	ZdddZZS)	_AppendConstActionNFc
s$tt|j||d|||||ddS)Nr)rrrrrrrzr)rr$rVrrr-r.rVs
z_AppendConstAction.__init__cCs4t||jd}t|}||jt||j|dSr0)r	rr:r!rrr#r-r-r.rsz_AppendConstAction.__call__)NFNN)Nrr-r-rr.r$sr$cs(eZdZdfdd	ZdddZZS)	_CountActionNFcs tt|j||d|||ddS)Nr)rrrrrrz)rr%rVrrr-r.rVs
z_CountAction.__init__cCs0t||jd}|dkrd}t||j|ddSNrrX)r	rr)r&rrrrcountr-r-r.rsz_CountAction.__call__)NFN)Nrr-r-rr.r%s
r%cs.eZdZeedffdd	ZdddZZS)_HelpActionNcstt|j|||d|ddSNr)rrrrrz)rr(rV)r&rrrrzrr-r.rVs
z_HelpAction.__init__cCs||dSr0)
print_helpexitrr-r-r.rsz_HelpAction.__call__)Nrr5r6rrVrrr-r-rr.r(s
r(cs0eZdZdeedffdd	ZdddZZS)_VersionActionNz&show program's version number and exitcs$tt|j|||d|d||_dSr))rr-rVversion)r&rr.rrrzrr-r.rVs
z_VersionAction.__init__cCsD|j}|dkr|j}|}||||tj|dSr0)r._get_formatterro_print_messagerh_sysstdoutr+)r&rrrrr.r\r-r-r.r(s
z_VersionAction.__call__)Nr,r-r-rr.r-sr-csPeZdZGdddeZedddffdd	ZddZd	d
Zd
ddZ	Z
S)_SubParsersActioncseZdZfddZZS)z&_SubParsersAction._ChoicesPseudoActioncs@|}}|r|dd|7}ttj|}|jg|||ddS)Nrr)rrrzr)r%rr3_ChoicesPseudoActionrV)r&r+aliasesrzrrsuprr-r.rV6s
z/_SubParsersAction._ChoicesPseudoAction.__init__r r-r-rr.r44sr4FNc	s<||_||_i|_g|_tt|j||t|j|||ddS)N)rrrrrrzr)_prog_prefix
_parser_class_name_parser_map_choices_actionsrr3rVr)r&rrRparser_classrrrzrrr-r.rV>s	
z_SubParsersAction.__init__cKs|ddkr d|j|f|d<|dd}d|krX|d}||||}|j||jf|}||j|<|D]}||j|<qr|S)NrRrr5r-rz)rr7rr4r:r!r8r9)r&r+kwargsr5rz
choice_actionraliasr-r-r.
add_parserUs

z_SubParsersAction.add_parsercCs|jSr0)r:r4r-r-r.rlsz!_SubParsersAction._get_subactionscCs|d}|dd}|jtk	r,t||j|z|j|}Wn<tk
rv|d|jd}td|}t||YnX||d\}	}t	|	
D]\}
}t||
|q|rt	|tgt
|t|dS)NrrXr)parser_namerz5unknown parser %(parser_name)r (choices: %(choices)s))rrrr9KeyErrorr%rrparse_known_argsrr3
setdefault_UNRECOGNIZED_ARGS_ATTRr	r)r&rrrrr@r(ramsgsubnamespacekeyr,r-r-r.ros$

	z_SubParsersAction.__call__)N)rr5r6rr4rrVr?rrrr-r-rr.r32sr3c@seZdZdddZdS)
_ExtendActionNcCs2t||jd}t|}||t||j|dSr0)r	rr:rrr#r-r-r.rs
z_ExtendAction.__call__)N)rr5r6rr-r-r-r.rHsrHc@s*eZdZdZdddZddZd	d
ZdS)raFactory for creating file object types

    Instances of FileType are typically passed as type= arguments to the
    ArgumentParser add_argument() method.

    Keyword Arguments:
        - mode -- A string indicating how the file is to be opened. Accepts the
            same values as the builtin open() function.
        - bufsize -- The file's desired buffer size. Accepts the same values as
            the builtin open() function.
        - encoding -- The file's encoding. Accepts the same values as the
            builtin open() function.
        - errors -- A string indicating how encoding and decoding errors are to
            be handled. Accepts the same value as the builtin open() function.
    rrNcCs||_||_||_||_dSr0)_mode_bufsize	_encoding_errors)r&modebufsizeencodingerrorsr-r-r.rVszFileType.__init__c
Cs|dkr>d|jkrtjSd|jkr(tjStd|j}t|zt||j|j|j|j	WSt
k
r}z"||d}td}t||W5d}~XYnXdS)N-rIwzargument "-" with mode %r)filenameerrorz$can't open '%(filename)s': %(error)s)rJr1stdinr2rrrrKrLrMOSErrorr)r&stringrEerarr-r-r.rs


zFileType.__call__cCsT|j|jf}d|jfd|jfg}ddd|Ddd|D}dt|j|fS)NrPrQrcSsg|]}|dkrt|qS)r)r")r_r*r-r-r.rbsz%FileType.__repr__.<locals>.<listcomp>cSs$g|]\}}|dk	rd||fqS)Nrr-)r_kwr*r-r-r.rbsr)rJrKrLrMr%rr)r&rar<args_strr-r-r.r/szFileType.__repr__)rIrNN)rr5r6r7rVrr/r-r-r-r.rs
c@s(eZdZdZddZddZddZdS)	r
zSimple object for storing attributes.

    Implements equality by attribute names and values, and provides a simple
    string representation.
    cKs|D]}t||||qdSr0)r)r&r<r+r-r-r.rVszNamespace.__init__cCst|tstSt|t|kSr0)rr
NotImplementedr)r&otherr-r-r.__eq__s
zNamespace.__eq__cCs
||jkSr0)r2)r&rGr-r-r.__contains__szNamespace.__contains__N)rr5r6r7rVr^r_r-r-r-r.r
scseZdZfddZddZd&ddZdd	Zd
dZdd
ZddZ	ddZ
ddZddZddZ
ddZddZd'ddZddZd d!Zd"d#Zd$d%ZZS)(_ActionsContainercstt|||_||_||_||_i|_|ddt	|ddt	|ddt
|ddt|ddt|ddt
|ddt|ddt|dd	t|dd
t|ddt|ddt|g|_i|_g|_g|_i|_td
|_g|_dS)Nr~storestore_const
store_truestore_falser!append_constr'rzr.parsersrz^-\d+$|^-\d*\.\d+$)rr`rVdescriptionargument_defaultprefix_charsconflict_handler_registriesregisterrrrr!r"r$r%r(r-r3rH_get_handler_actions_option_string_actions_action_groups_mutually_exclusive_groups	_defaultsrMrN_negative_number_matcher_has_negative_number_optionals)r&rgrirhrjrr-r.rVs4z_ActionsContainer.__init__cCs|j|i}|||<dSr0)rkrC)r&
registry_namer,rregistryr-r-r.rlsz_ActionsContainer.registerNcCs|j|||Sr0)rkr)r&rur,rr-r-r.
_registry_get sz_ActionsContainer._registry_getcKs2|j||jD]}|j|kr||j|_qdSr0)rrupdaternrr)r&r<r~r-r-r.set_defaults&s

z_ActionsContainer.set_defaultscCs8|jD]"}|j|kr|jdk	r|jSq|j|dSr0)rnrrrrr)r&rr~r-r-r.get_default/s
z_ActionsContainer.get_defaultcOsD|j}|r&t|dkrH|dd|krH|r:d|kr:td|j||}n|j||}d|kr|d}||jkr~|j||d<n|jdk	r|j|d<||}t|std|f|f|}|	d|j
|j
}t|std	|f|tkrtd
|ft|dr:z|
|dWntk
r8tdYnX||S)
z
        add_argument(dest, ..., name=value, ...)
        add_argument(option_string, option_string, ..., name=value, ...)
        rXrrz+dest supplied twice for positional argumentrNzunknown action "%s"r%r is not callablez<%r is a FileType class object, instance of it must be passedr/z,length of metavar tuple does not match nargs)rirwr_get_positional_kwargs_get_optional_kwargsrrrh_pop_action_classcallablerwrrrr/rr_add_action)r&rar<charsraction_classr~	type_funcr-r-r.r9s:	 




z_ActionsContainer.add_argumentcOs t|f||}|j||Sr0)_ArgumentGrouprpr!)r&rar<rr-r-r.add_argument_grouplsz$_ActionsContainer.add_argument_groupcKst|f|}|j||Sr0)_MutuallyExclusiveGrouprqr!)r&r<rr-r-r.add_mutually_exclusive_groupqsz._ActionsContainer.add_mutually_exclusive_groupcCs`|||j|||_|jD]}||j|<q"|jD]"}|j|r8|js8|jdq8|S)NT)	_check_conflictrnr!	containerrrorsmatchrt)r&r~rr-r-r.rvs


z_ActionsContainer._add_actioncCs|j|dSr0)rnremoverr-r-r._remove_actionsz _ActionsContainer._remove_actioncCsi}|jD].}|j|kr.td}t||j|||j<q
i}|jD]D}|j|krn|j|j|j|jd||j<|jD]}||j||<qtqD|jD]&}|j	|j
d}|jD]}|||<qq|jD]}|||
|qdS)Nz.cannot merge actions - two groups are named %r)titlergrj)r)rprrrrrgrjrrqrrrnrr)r&rtitle_group_maprrE	group_mapr~mutex_groupr-r-r._add_container_actionss0







z(_ActionsContainer._add_container_actionscKs^d|krtd}t||dttfkr2d|d<|dtkrPd|krPd|d<t||gdS)Nrz1'required' is an invalid argument for positionalsrTrrr)rrrr
rr)r&rr<rEr-r-r.r|sz(_ActionsContainer._get_positional_kwargsc	Osg}g}|D]n}|d|jkr>||jd}td}t|||||d|jkrt|dkr|d|jkr||q|dd}|dkr|r|d}n|d}||j}|std}t|||dd}t|||d	S)
Nr)optionrizNinvalid option string %(option)r: must start with a character %(prefix_chars)rrXrz%dest= is required for options like %rrRrr)	rirrr!rwrlstripreplacer)	r&rar<rlong_option_stringsrrErdest_option_stringr-r-r.r}s2

z&_ActionsContainer._get_optional_kwargscCs|d|}|d||S)Nr~)rrw)r&r<rr~r-r-r.r~sz#_ActionsContainer._pop_action_classcCsFd|j}zt||WStk
r@td}t||jYnXdS)Nz_handle_conflict_%sz%invalid conflict_resolution value: %r)rjr	rrr)r&handler_func_namerEr-r-r.rms
z_ActionsContainer._get_handlercCsLg}|jD]&}||jkr
|j|}|||fq
|rH|}|||dSr0)rror!rm)r&r~confl_optionalsrconfl_optionalrjr-r-r.rs


z!_ActionsContainer._check_conflictcCs6tddt|}ddd|D}t|||dS)Nzconflicting option string: %szconflicting option strings: %srcSsg|]\}}|qSr-r-)r_rr~r-r-r.rb	sz<_ActionsContainer._handle_conflict_error.<locals>.<listcomp>)rrwr%r)r&r~conflicting_actionsrconflict_stringr-r-r._handle_conflict_errors
z(_ActionsContainer._handle_conflict_errorcCs>|D]4\}}|j||j|d|js|j|qdSr0)rrrorrr)r&r~rrr-r-r._handle_conflict_resolves
z*_ActionsContainer._handle_conflict_resolve)N)N)rr5r6rVrlrwryrzrrrrrrr|r}r~rmrrrrr-r-rr.r`s$5
	
3($
		r`cs6eZdZdfdd	ZfddZfddZZS)	rNcs|j}|d|j|d|j|d|jtt|j}|fd|i|||_g|_|j	|_	|j
|_
|j|_|j|_|j
|_
|j|_dS)Nrjrirhrg)rCrjrirhrrrVrrrkrnrorrrtrq)r&rrrgr<rx
super_initrr-r.rVsz_ArgumentGroup.__init__cs tt||}|j||Sr0)rrrrr!rrr-r.r5sz_ArgumentGroup._add_actioncs tt|||j|dSr0)rrrrrrrr-r.r:sz_ArgumentGroup._remove_action)NNrr5r6rVrrrr-r-rr.rsrcs.eZdZdfdd	ZddZddZZS)	rFcs tt||||_||_dSr0)rrrVr
_container)r&rrrr-r.rVAsz _MutuallyExclusiveGroup.__init__cCs2|jrtd}t||j|}|j||S)Nz-mutually exclusive arguments must be optional)rrrrrrr!)r&r~rEr-r-r.rFsz#_MutuallyExclusiveGroup._add_actioncCs|j||j|dSr0)rrrrrr-r-r.rNsz&_MutuallyExclusiveGroup._remove_action)Frr-r-rr.r?srcs*eZdZdZddddgeddddddffdd	Zdd	Zd
dZdd
ZddZ	ddZ
dAddZdBddZddZ
ddZddZddZddZd d!Zd"d#Zd$d%ZdCd&d'ZdDd(d)Zd*d+Zd,d-Zd.d/Zd0d1Zd2d3Zd4d5ZdEd6d7ZdFd8d9ZdGd:d;ZdHd=d>Z d?d@Z!Z"S)IraObject for parsing command line strings into Python objects.

    Keyword Arguments:
        - prog -- The name of the program (default: sys.argv[0])
        - usage -- A usage message (default: auto-generated from arguments)
        - description -- A description of what the program does
        - epilog -- Text following the argument descriptions
        - parents -- Parsers whose arguments should be copied into this one
        - formatter_class -- HelpFormatter class for printing help messages
        - prefix_chars -- Characters that prefix optional arguments
        - fromfile_prefix_chars -- Characters that prefix files containing
            additional arguments
        - argument_default -- The default value for all arguments
        - conflict_handler -- String indicating how to handle conflicts
        - add_help -- Add a -h/-help option
        - allow_abbrev -- Allow long options to be abbreviated unambiguously
    NrRrUTc
	s"tt|j}
|
|||	|
d|dkr6tjtjd}||_||_	||_
||_||_||_
||_|j}|td|_|td|_d|_dd}|dd|d|krdn|d}|j
r|j|d	|d
ddttdd
|D]<}||z
|j}Wntk
rYqX|j|qdS)N)rgrirhrjrzpositional argumentszoptional argumentscSs|Sr0r-)rXr-r-r.identitysz)ArgumentParser.__init__.<locals>.identityrrRhr;rzzshow this help message and exit)r~rrz)rrrV_ospathbasenamer1argvrRrqepilogformatter_classfromfile_prefix_charsadd_helpallow_abbrevrr_positionals
_optionals_subparsersrlrrrrrrrx)r&rRrqrgrparentsrrirrhrjrr	superinit	add_grouprdefault_prefixr]defaultsrr-r.rVfsJ


zArgumentParser.__init__cs"ddddddg}fdd|DS)	NrRrqrgrrjrcsg|]}|t|fqSr-rr
r4r-r.rbsz.ArgumentParser._get_kwargs.<locals>.<listcomp>r-rr-r4r.r#szArgumentParser._get_kwargsc	Ks|jdk	r|td|dt|d|ks8d|krht|dd}t|dd}||||_n|j|_|ddkr|	}|
}|j}||j
||d||d<||d}|fd	gi|}|j||S)
Nz(cannot have multiple subparser argumentsr;rrgsubcommandsrRrcrfr)rrUrrCrrrrrr/_get_positional_actionsrqrurqrhrr~r)	r&r<rrgr\rrs
parsers_classr~r-r-r.add_subparserss$
zArgumentParser.add_subparserscCs$|jr|j|n|j||Sr0)rrrrrr-r-r.rszArgumentParser._add_actioncCsdd|jDS)NcSsg|]}|jr|qSr-rr_r~r-r-r.rbsz8ArgumentParser._get_optional_actions.<locals>.<listcomp>rnr4r-r-r._get_optional_actionssz$ArgumentParser._get_optional_actionscCsdd|jDS)NcSsg|]}|js|qSr-rrr-r-r.rbsz:ArgumentParser._get_positional_actions.<locals>.<listcomp>rr4r-r-r.rsz&ArgumentParser._get_positional_actionscCs4|||\}}|r0td}||d||SNzunrecognized arguments: %sr)rBrrUr%r&rarrrEr-r-r.
parse_argss
zArgumentParser.parse_argscCs|dkrtjdd}nt|}|dkr.t}|jD]4}|jtk	r4t||js4|jtk	r4t	||j|jq4|j
D] }t||spt	|||j
|qpz>|||\}}t|tr|
t|tt|t||fWStk
rtd}|t|YnXdSrW)r1rr8r
rnrrrrrrr_parse_known_argsrDrr	delattrrexc_inforUr)r&rarr~rerrr-r-r.rBs,







zArgumentParser.parse_known_argscs	jdk	r	i	jD]R}|j}t|jD]<\}}|g}||d||||ddq2qig}t}	t|	D]^\}}
|
dkr|d|	D]}
|dqq		|
}|dkrd}n||<d}||qd
|ttd	fdd		fd	d
}
		fdd}gd
r`t
}nd}
|krt
fddD}
|kr|
}|
kr|
qdn|

kr҈
|}||
|

qd|
}|dg}	jD]|}|kr|jr(|t|nT|jdk	rt|jtrt|jr|jt|jkrt|j	||jq|r	tdd
|	jD]X}|jr|jD]}|krqqdd|jD}td}	|d
|qfS)NrX--rRAOrccs||||}||jk	rb||gD]*}|kr6td}t|}t|||q6|tk	rx|||dS)Nznot allowed with argument %s)r_get_valuesrrrrrr)r~argument_stringsrargument_valuesconflict_actionrEaction_name)action_conflictsrseen_actionsseen_non_default_actionsr&r-r.take_action@s


z5ArgumentParser._parse_known_args.<locals>.take_actioncs|}|\}}}j}g}|dkr:||dS|dk	r||d}j}|dkr|d|kr||g|f|d}	|	|d}|ddpd}
j}||kr||}|
}ntd}t|||nB|dkr|d}
|g}||||fq\ntd}t|||q|d}|d}|||}||}
||
}||||fq\q|sft|D]\}}}|||qj|
S)NrXrrzignored explicit argument %r)_match_argumentr!rirorrrZ)start_indexoption_tupler~rexplicit_argmatch_argument
action_tuples	arg_countrcharnew_explicit_arg
optionals_maprEstoprarselected_patterns)r(arg_strings_patternextrasoption_string_indicesr&rr-r.consume_optionalUsN




z:ArgumentParser._parse_known_args.<locals>.consume_optionalcsnj}|d}||}t|D]*\}}|||}||7}||q&t|ddd<|Sr0)_match_arguments_partialziprw)r
match_partialselected_pattern
arg_countsr~rra)r(rrr&rr-r.consume_positionalss
z=ArgumentParser._parse_known_args.<locals>.consume_positionalsrrcsg|]}|kr|qSr-r-)r_r)rr-r.rbsz4ArgumentParser._parse_known_args.<locals>.<listcomp>z(the following arguments are required: %srcSsg|]}|jtk	rt|qSr-)rzrrrr-r-r.rbs
z#one of the arguments %s is requiredr)N)r_read_args_from_filesrqrrrCriterr!_parse_optionalr%rrrDrCrnrrrrrrrr	r
_get_valuerUr)r&r(rrrrmutex_action	conflictsarg_string_pattern_partsarg_strings_iter
arg_stringrpatternrrmax_option_string_indexnext_option_string_indexpositionals_end_indexstrings
stop_indexrequired_actionsr~rrrEr-)rr(rrrrrrrr&rrr.rs





J














z ArgumentParser._parse_known_argsc
Csg}|D]}|r|d|jkr*||qzdt|ddJ}g}|D]}||D]}||q\qN||}||W5QRXWqtk
rt	
d}|t|YqXq|Sr&)
rr!rreadrconvert_arg_line_to_argsrrrWr1rrUr)r&r(new_arg_stringsr	args_filearg_liner*rr-r-r.rs 
z$ArgumentParser._read_args_from_filescCs|gSr0r-)r&rr-r-r.r!sz'ArgumentParser.convert_arg_line_to_argscCsz||}t||}|dkrldtdttdttdi}||j}|dkrbtdd|j|j}t	||t
|dS)Nzexpected one argumentzexpected at most one argumentzexpected at least one argumentzexpected %s argumentzexpected %s argumentsrX)_get_nargs_patternrMrrr
rrrrrrwr)r&r~r
nargs_patternrnargs_errorsrEr-r-r.r$s(

zArgumentParser._match_argumentcsrg}tt|ddD]X}|d|}dfdd|D}t||}|dk	r|dd|Dqnq|S)Nrrrccsg|]}|qSr-)rrr4r-r.rb@sz;ArgumentParser._match_arguments_partial.<locals>.<listcomp>cSsg|]}t|qSr-rv)r_rXr-r-r.rbDs)rrwr%rMrrrs)r&rrrrr
actions_slicerrr-r4r.r:sz'ArgumentParser._match_arguments_partialc
Cs|sdS|d|jkrdS||jkr8|j|}||dfSt|dkrHdSd|kr~|dd\}}||jkr~|j|}|||fS||}t|dkrddd|D}||d}td}|||nt|dkr|\}	|	S|j	|r|j
sdSd	|krdSd|dfS)
NrrX=rcSsg|]\}}}|qSr-r-)r_r~rrr-r-r.rbisz2ArgumentParser._parse_optional.<locals>.<listcomp>)rmatchesz4ambiguous option: %(option)s could match %(matches)sr)rirorwsplit_get_option_tuplesr%rrUrsrrt)
r&rr~rr
option_tuplesoptionsrarErr-r-r.rJs>









zArgumentParser._parse_optionalc
Cs0g}|j}|d|kr|d|kr|jr~d|krB|dd\}}n|}d}|jD],}||rP|j|}|||f}||qPn|d|kr|d|kr|}d}|dd}|dd}	|jD]T}||kr|j|}|||	f}||q||r|j|}|||f}||qn|td||S)NrrXrr;zunexpected option string: %s)rirrro
startswithr!rUr)
r&rrr
option_prefixrr~rshort_option_prefixshort_explicit_argr-r-r.rs:









z!ArgumentParser._get_option_tuplescCs|j}|dkrd}nf|tkr"d}nX|tkr0d}nJ|tkr>d}n<|tkrLd}n.|tkrZd}n |tkrhd}ndd	d
|}|jr|	d	d}|	dd}|S)
Nz(-*A-*)z(-*A?-*)z	(-*[A-]*)z
(-*A[A-]*)z([-AO]*)z(-*A[-AO]*)z(-*-*)z(-*%s-*)z-*rrcrR)
rr
rrrrrr%rr)r&r~rrr-r-r.rs(z!ArgumentParser._get_nargs_patterncCs4|||\}}|r0td}||d||Sr)parse_known_intermixed_argsrrUr%rr-r-r.parse_intermixed_argss
z$ArgumentParser.parse_intermixed_argsc	s|ddD}|r,td|djfdd|jDrHtdzN|j}z|jdkrp|dd|_D] }|j|_t	|_|j|_t	|_qt|
||\}}D]J}t||jrt
||jgkrddlm}|d	|j|ft||jqW5D]}|j|_|j|_qX|}zJ|D]}|j|_d
|_q$|jD]}	|	j|	_d
|	_q@|
||\}}
W5|D]}|j|_qn|jD]}	|	j|	_qXW5||_X||
fS)NcSsg|]}|jttfkr|qSr-)rrrrr-r-r.rbsz>ArgumentParser.parse_known_intermixed_args.<locals>.<listcomp>z3parse_intermixed_args: positional arg with nargs=%srcs&g|]}|jD]}|kr|jqqSr-)rr)r_rr~rr-r.rbs
z;parse_intermixed_args: positional in mutuallyExclusiveGroup)warnzDo not expect %s in %sF)rrrrqrq
save_nargssave_defaultrformat_usagerrBrrr	warningsr
rr
save_requiredr)r&rara
save_usager~remaining_argsr
rrrr-rr.r	s`





z*ArgumentParser.parse_known_intermixed_argscsjttfkr2z|dWntk
r0YnX|szjtkrzjrNj}nj}t	|t
rv|}|n|sjt
krjsjdk	rj}n|}|nt|dkrjdtfkr|\}|}|njtkrfdd|D}npjtkr@fdd|D}|dn>jtkrRt}n,fdd|D}|D]}|qj|S)NrrXcsg|]}|qSr-rr_vr~r&r-r.rbZ	sz.ArgumentParser._get_values.<locals>.<listcomp>csg|]}|qSr-rrrr-r.rb^	srcsg|]}|qSr-rrrr-r.rbg	s)rrrrrr
rrrrrr_check_valuerrwr)r&r~r(r,rrr-rr.r6	sD

zArgumentParser._get_valuesc	Cs|d|j|j}t|s0td}t|||z||}Wntk
r~t|jdt|j}tt	
d}t||YnLttfk
rt|jdt|j}||d}td}t|||YnX|S)Nrr{rrX)rr,z!invalid %(type)s value: %(value)r)
rwrrrrrr	r"rr1rrr)r&r~rrrErr+rar-r-r.rn	s 
zArgumentParser._get_valuecCsF|jdk	rB||jkrB|dtt|jd}td}t|||dS)Nr)r,rz3invalid choice: %(value)r (choose from %(choices)s))rr%mapr"rr)r&r~r,rarEr-r-r.r	szArgumentParser._check_valuecCs$|}||j|j|j|Sr0)r/rurqrnrqrh)r&r\r-r-r.r	s
zArgumentParser.format_usagecCst|}||j|j|j||j|jD]0}||j	||j|
|j|q.||j
|Sr0)r/rurqrnrqrorgrprkrrrrlrrh)r&r\action_groupr-r-r.rh	s

zArgumentParser.format_helpcCs|j|jdS)Nr)rrRr4r-r-r.r/	szArgumentParser._get_formattercCs"|dkrtj}|||dSr0)r1r2r0rr&filer-r-r.print_usage	szArgumentParser.print_usagecCs"|dkrtj}|||dSr0)r1r2r0rhrr-r-r.r*	szArgumentParser.print_helpcCs |r|dkrtj}||dSr0)r1stderrwrite)r&rrr-r-r.r0	szArgumentParser._print_messagercCs |r||tjt|dSr0)r0r1r r+)r&statusrr-r-r.r+	szArgumentParser.exitcCs0|tj|j|d}|dtd|dS)zerror(message: string)

        Prints a usage message incorporating the message to stderr and
        exits.

        If you override this in a subclass, it should not return -- it
        should either exit or raise an exception.
        )rRrr;z%(prog)s: error: %(message)s
N)rr1r rRr+r)r&rrar-r-r.rU	s	zArgumentParser.error)NN)NN)NN)NN)N)N)N)rN)#rr5r6r7rrVr#rrrrrrBrrrrrrrrr
r	rrrrrhr/rr*r0r+rUrr-r-rr.rSsV@

#w:-1

M8


	
)3r7__version____all__osrrerMshutilr>sysr1rrrrr
rrrrrDrrr:rrrrr	r	Exceptionrrrrrrr!r"r$r%r(r-r3rHrr
r`rrrr-r-r-r.<module>s=z
	[#&]7:"

Zerion Mini Shell 1.0