ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python39/lib64/python3.9/__pycache__/argparse.cpython-39.pyc

a

���eG�@sdZdZgd�ZddlZddlZddlZddl	m	Z
mZdZdZ
dZd	Zd
ZdZdZGd
d�de�Zdd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zdd�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�Z Gd%d&�d&e�Z!Gd'd(�d(e�Z"Gd)d*�d*e"�Z#Gd+d,�d,e"�Z$Gd-d.�d.e�Z%Gd/d0�d0e�Z&Gd1d2�d2e�Z'Gd3d4�d4e�Z(Gd5d6�d6e�Z)Gd7d8�d8e�Z*Gd9d:�d:e%�Z+Gd;d<�d<e�Z,Gd=d>�d>e�Z-Gd?d@�d@e�Z.GdAdB�dBe.�Z/GdCdD�dDe/�Z0GdEdF�dFee.�Z1dS)Ga�
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.1)�ArgumentParser�
ArgumentError�ArgumentTypeError�BooleanOptionalAction�FileType�
HelpFormatter�ArgumentDefaultsHelpFormatter�RawDescriptionHelpFormatter�RawTextHelpFormatter�MetavarTypeHelpFormatter�	Namespace�Action�ONE_OR_MORE�OPTIONAL�PARSER�	REMAINDER�SUPPRESS�ZERO_OR_MORE�N)�gettext�ngettextz==SUPPRESS==�?�*�+zA...�...Z_unrecognized_argsc@s(eZdZdZdd�Zdd�Zdd�ZdS)	�_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__.
    cCs�t|�j}g}i}|��D]}|�t|��q|��D],\}}|��rZ|�d||f�q6|||<q6|rz|�dt|��d|d�|�fS)N�%s=%rz**%s�%s(%s)�, )�type�__name__�	_get_args�append�repr�_get_kwargs�isidentifier�join)�selfZ	type_name�arg_stringsZ	star_args�arg�name�value�r+�-/opt/alt/python39/lib64/python3.9/argparse.py�__repr__ts

z_AttributeHolder.__repr__cCst|j���S�N)�list�__dict__�items�r&r+r+r,r#�sz_AttributeHolder._get_kwargscCsgSr.r+r2r+r+r,r �sz_AttributeHolder._get_argsN)r�
__module__�__qualname__�__doc__r-r#r r+r+r+r,rksrcCs6|durgSt|�tur$|dd�Sddl}|�|�S�Nr)rr/�copy)r1r7r+r+r,�_copy_items�sr8c@s�eZdZdZd;dd�Zdd�Zd	d
�ZGdd�de�Zd
d�Z	dd�Z
dd�Zdd�Zd<dd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�ZdS)=rz�Formatter 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�|dur"ddl}|��j}|d8}||_||_t|t|d|d��|_||_d|_	d|_
d|_|�|d�|_
|j
|_t�dtj�|_t�d�|_dS)Nrr9�z\s+z\n\n\n+)�shutil�get_terminal_size�columns�_prog�_indent_increment�min�max�_max_help_position�_width�_current_indent�_level�_action_max_length�_Section�
_root_section�_current_section�_re�compile�ASCII�_whitespace_matcher�_long_break_matcher)r&�progZindent_incrementZmax_help_position�widthr<r+r+r,�__init__�s"
�zHelpFormatter.__init__cCs"|j|j7_|jd7_dS�N��rEr@rFr2r+r+r,�_indent�szHelpFormatter._indentcCs4|j|j8_|jdks"Jd��|jd8_dS)NrzIndent decreased below 0.rTrUr2r+r+r,�_dedent�szHelpFormatter._dedentc@seZdZddd�Zdd�ZdS)zHelpFormatter._SectionNcCs||_||_||_g|_dSr.)�	formatter�parent�headingr1)r&rXrYrZr+r+r,rR�szHelpFormatter._Section.__init__cCs�|jdur|j��|jj}|dd�|jD��}|jdurD|j��|sLdS|jturz|jdurz|jj}d|d|jf}nd}|d||dg�S)NcSsg|]\}}||��qSr+r+)�.0�func�argsr+r+r,�
<listcomp>��z6HelpFormatter._Section.format_help.<locals>.<listcomp>�z%*s%s:
�
)	rYrXrV�_join_partsr1rWrZrrE)r&r%Z	item_helpZcurrent_indentrZr+r+r,�format_help�s



z"HelpFormatter._Section.format_help)N)rr3r4rRrcr+r+r+r,rH�s
rHcCs|jj�||f�dSr.)rJr1r!)r&r\r]r+r+r,�	_add_item�szHelpFormatter._add_itemcCs0|��|�||j|�}|�|jg�||_dSr.)rVrHrJrdrc)r&rZZsectionr+r+r,�
start_section�szHelpFormatter.start_sectioncCs|jj|_|��dSr.)rJrYrWr2r+r+r,�end_section�s
zHelpFormatter.end_sectioncCs$|tur |dur |�|j|g�dSr.)rrd�_format_text)r&�textr+r+r,�add_text�szHelpFormatter.add_textcCs&|tur"||||f}|�|j|�dSr.)rrd�
_format_usage)r&�usage�actions�groups�prefixr]r+r+r,�	add_usage�szHelpFormatter.add_usagecCsr|jturn|j}||�g}|�|�D]}|�||��q$ttt|��}||j}t|j	|�|_	|�
|j|g�dSr.)�helpr�_format_action_invocation�_iter_indented_subactionsr!rB�map�lenrErGrd�_format_action)r&�actionZget_invocationZinvocations�	subactionZinvocation_lengthZ
action_lengthr+r+r,�add_arguments


�zHelpFormatter.add_argumentcCs|D]}|�|�qdSr.)rx)r&rlrvr+r+r,�
add_argumentsszHelpFormatter.add_argumentscCs.|j��}|r*|j�d|�}|�d�d}|S)N�

ra)rIrcrO�sub�strip)r&rpr+r+r,rcs

zHelpFormatter.format_helpcCsd�dd�|D��S)Nr`cSsg|]}|r|tur|�qSr+)r)r[�partr+r+r,r^"s�z-HelpFormatter._join_parts.<locals>.<listcomp>)r%)r&Zpart_stringsr+r+r,rb!s
�zHelpFormatter._join_partscs6|durtd�}|dur,|t|jd�}�n�|durL|sLdt|jd�}�n�|du�r*dt|jd�}g}g}|D] }|jr�|�|�qr|�|�qr|j}	|	|||�}
d�dd�||
fD��}|j|j�t	|�t	|��k�r*d}|	||�}|	||�}
t
�||�}t
�||
�}d�|�|k�s&J�d�|�|
k�s:J�d�fdd	�	}t	|�t	|�d
�k�r�dt	|�t	|�d}|�r�||g|||�}|�|||��n |�r�||g|||�}n|g}nZdt	|�}||}|||�}t	|�dk�rg}|�|||��|�|||��|g|}d�|�}d
||fS)Nzusage: �rPz%(prog)s� cSsg|]}|r|�qSr+r+)r[�sr+r+r,r^Br_z/HelpFormatter._format_usage.<locals>.<listcomp>z%\(.*?\)+(?=\s|$)|\[.*?\]+(?=\s|$)|\S+cs�g}g}|durt|�d}nt|�d}|D]Z}|dt|��krn|rn|�|d�|��g}t|�d}|�|�|t|�d7}q.|r�|�|d�|��|dur�|dt|�d�|d<|S)NrTrr)rtr!r%)�parts�indentrn�lines�lineZline_lenr}��
text_widthr+r,�	get_linesVs"
z.HelpFormatter._format_usage.<locals>.get_linesg�?rTraz%s%s

)N)
�_�dictr?�option_stringsr!�_format_actions_usager%rDrErtrK�findall�extend)r&rkrlrmrnrP�	optionals�positionalsrv�formatZaction_usageZpart_regexpZ	opt_usageZ	pos_usageZ	opt_partsZ	pos_partsr�r�r�r�r+r�r,rj&s\
�




zHelpFormatter._format_usagec	Cst�}i}|D�]*}|js(td|����z|�|jd�}WntyRYqYq0|t|j�}|||�|jkr|jD]}|�|�qz|js�||vr�||d7<nd||<||vr�||d7<nd||<nF||vr�||d7<nd||<||v�r||d7<nd||<t|d	|�D]}	d
||	<�q*qg}
t|�D�]"\}	}|j	t
u�r�|
�d�|�|	�d
k�r�|�
|	�n"|�|	d	�d
k�rj|�
|	d	�n�|j�s|�|�}|�||�}||v�r�|ddk�r�|ddk�r�|d	d�}|
�|�nf|jd}
|jdk�r$|��}n"|�|�}|�||�}d|
|f}|j�s`||v�r`d
|}|
�|��qHt|dd�D]}	||	g|
|	|	�<�qzd�dd�|
D��}d}d}t�d|d|�}t�d|d|�}t�d||fd|�}t�dd|�}|��}|S)Nzempty group rz [�[�]z (�(�)rT�|����%s %s�[%s]T)�reversercSsg|]}|dur|�qSr.r+)r[�itemr+r+r,r^�r_z7HelpFormatter._format_actions_usage.<locals>.<listcomp>z[\[(]z[\])]z(%s) z\1� (%s)z%s *%sr`z\(([^|]*)\))�set�_group_actions�
ValueError�indexrt�add�required�range�	enumeraterprr!�get�popr��#_get_default_metavar_for_positional�_format_args�nargs�format_usage�!_get_default_metavar_for_optional�sortedr%rKr{r|)r&rlrm�
group_actionsZinserts�group�start�endrv�ir��defaultr}�
option_string�args_stringrh�open�closer+r+r,r��s~










z#HelpFormatter._format_actions_usagecCsFd|vr|t|jd�}t|j|jd�}d|j}|�|||�dS)Nz%(prog)r~�rrz)r�r?rBrDrE�
_fill_text)r&rhr�r�r+r+r,rg�s

zHelpFormatter._format_textc
CsNt|jd|j�}t|j|d�}||jd}|�|�}|jsV|jd|f}d|}n@t|�|kr~|jd||f}d|}d}n|jd|f}d|}|}|g}|j�r|j�	��r|�
|�}	|	�r"|�|	|�}
|�d|d|
df�|
dd�D]}|�d|d|f�q�n|�
d��s"|�d�|�|�D]}|�|�|���q,|�|�S)	Nr9r�r`z%*s%s
z	%*s%-*s  rrTra)rArGrCrBrDrErqrprtr|�_expand_help�_split_linesr!�endswithrrrurb)
r&rvZ
help_positionZ
help_widthZaction_widthZ
action_header�tupZindent_firstr�Z	help_textZ
help_linesr�rwr+r+r,ru�s:
�



zHelpFormatter._format_actioncCs�|js&|�|�}|�||�d�\}|Sg}|jdkrB|�|j�n4|�|�}|�||�}|jD]}|�d||f�q^d�|�SdS)NrTrr�r)	r�r��_metavar_formatterr�r�r�r�r!r%)r&rvr��metavarr�r�r�r+r+r,rq's



z'HelpFormatter._format_action_invocationcsP|jdur|j�n.|jdur<dd�|jD�}dd�|��n|��fdd�}|S)NcSsg|]}t|��qSr+��str)r[Zchoicer+r+r,r^Cr_z4HelpFormatter._metavar_formatter.<locals>.<listcomp>z{%s}�,cst�t�r�S�f|SdSr.)�
isinstance�tuple)Z
tuple_size��resultr+r,r�Hs
z0HelpFormatter._metavar_formatter.<locals>.format)r��choicesr%)r&rv�default_metavarZchoice_strsr�r+r�r,r�?s

z HelpFormatter._metavar_formattercCs|�||�}|jdur$d|d�}n�|jtkr<d|d�}n�|jtkrn|d�}t|�dkrdd|}nd|}n�|jtkr�d|d�}n�|jtkr�d}nr|jtkr�d	|d�}nZ|jtkr�d
}nJzdd�t	|j�D�}Wnt
y�td
�d�Yn0d�|�||j�}|S)N�%srTr�r9z
[%s [%s ...]]z[%s ...]z%s [%s ...]rz%s ...r`cSsg|]}d�qS)r�r+)r[r�r+r+r,r^er_z.HelpFormatter._format_args.<locals>.<listcomp>zinvalid nargs valuer)
r�r�rrrtr
rrrr��	TypeErrorr�r%)r&rvr�Zget_metavarr�r�Zformatsr+r+r,r�Os0








zHelpFormatter._format_argscCs�tt|�|jd�}t|�D]}||tur||=qt|�D] }t||d�r:||j||<q:|�d�dur�d�dd�|dD��}||d<|�	|�|S)Nr~rr�rcSsg|]}t|��qSr+r��r[�cr+r+r,r^tr_z.HelpFormatter._expand_help.<locals>.<listcomp>)
r��varsr?r/r�hasattrrr�r%�_get_help_string)r&rv�paramsr)Zchoices_strr+r+r,r�kszHelpFormatter._expand_helpccs>z
|j}WntyYn0|��|�EdH|��dSr.)�_get_subactions�AttributeErrorrVrW)r&rvZget_subactionsr+r+r,rrxs
z'HelpFormatter._iter_indented_subactionscCs&|j�d|���}ddl}|�||�S)Nrr)rNr{r|�textwrapZwrap)r&rhrQr�r+r+r,r��szHelpFormatter._split_linescCs,|j�d|���}ddl}|j||||d�S)Nrr)Zinitial_indentZsubsequent_indent)rNr{r|r�Zfill)r&rhrQr�r�r+r+r,r��s�zHelpFormatter._fill_textcCs|jSr.)rp�r&rvr+r+r,r��szHelpFormatter._get_help_stringcCs
|j��Sr.)�dest�upperr�r+r+r,r��sz/HelpFormatter._get_default_metavar_for_optionalcCs|jSr.)r�r�r+r+r,r��sz1HelpFormatter._get_default_metavar_for_positional)r9r:N)N) rr3r4r5rRrVrW�objectrHrdrerfrirorxryrcrbrjr�rgrurqr�r�r�rrr�r�r�r�r�r+r+r+r,r�s>�

`j0

rc@seZdZdZdd�ZdS)rz�Help 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 d��fdd�|jdd�D��S)Nr`c3s|]}�|VqdSr.r+)r[r��r�r+r,�	<genexpr>�r_z9RawDescriptionHelpFormatter._fill_text.<locals>.<genexpr>T)�keepends)r%�
splitlines)r&rhrQr�r+r�r,r��sz&RawDescriptionHelpFormatter._fill_textN)rr3r4r5r�r+r+r+r,r�src@seZdZdZdd�ZdS)r	z�Help 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|��Sr.)r�)r&rhrQr+r+r,r��sz!RawTextHelpFormatter._split_linesN)rr3r4r5r�r+r+r+r,r	�sr	c@seZdZdZdd�ZdS)rz�Help 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|jvr:|jtur:ttg}|js2|j|vr:|d7}|S)Nz
%(default)� (default: %(default)s))rpr�rrrr�r�)r&rvrpZdefaulting_nargsr+r+r,r��s

z.ArgumentDefaultsHelpFormatter._get_help_stringN)rr3r4r5r�r+r+r+r,r�src@s eZdZdZdd�Zdd�ZdS)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|jjSr.�rrr�r+r+r,r��sz:MetavarTypeHelpFormatter._get_default_metavar_for_optionalcCs|jjSr.r�r�r+r+r,r��sz<MetavarTypeHelpFormatter._get_default_metavar_for_positionalN)rr3r4r5r�r�r+r+r+r,r
�sr
cCsh|durdS|jrd�|j�S|jdtfvr2|jS|jdtfvrF|jS|jr`dd�|j�dSdSdS)N�/�{r��})r�r%r�rr�r�)�argumentr+r+r,�_get_action_name�sr�c@s eZdZdZdd�Zdd�ZdS)rz�An 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|�|_||_dSr.)r��
argument_name�message)r&r�r�r+r+r,rR�s
zArgumentError.__init__cCs(|jdurd}nd}|t|j|jd�S)Nz%(message)sz'argument %(argument_name)s: %(message)s)r�r�)r�r�r�)r&r�r+r+r,�__str__�s
�zArgumentError.__str__N)rr3r4r5rRr�r+r+r+r,r�src@seZdZdZdS)rz@An error from trying to convert a command line string to a type.N)rr3r4r5r+r+r+r,r�src@s4eZdZdZddd�Zdd�Zdd	�Zd
d
d�ZdS)ra\	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@||_||_||_||_||_||_||_||_|	|_|
|_	dSr.�
r�r�r��constr�rr�r�rpr��r&r�r�r�r�r�rr�r�rpr�r+r+r,rR4szAction.__init__csgd�}�fdd�|D�S)Nr�csg|]}|t�|�f�qSr+��getattr�r[r)r2r+r,r^Wr_z&Action._get_kwargs.<locals>.<listcomp>r+�r&�namesr+r2r,r#JszAction._get_kwargscCs
|jdSr6�r�r2r+r+r,r�YszAction.format_usagecCsttd���dS)Nz.__call__() not defined)�NotImplementedErrorr��r&�parser�	namespace�valuesr�r+r+r,�__call__\szAction.__call__)NNNNNFNN)N)rr3r4r5rRr#r�r�r+r+r+r,rs5�
rcs0eZdZd	�fdd�	Zd
dd�Zdd�Z�ZS)rNFc	s~g}	|D]2}
|	�|
�|
�d�rd|
dd�}
|	�|
�q|dur\|dur\|tur\|d7}t�j|	|d||||||d�	dS)N�--�--no-r9r�r)	r�r�r�r�rr�r�rpr�)r!�
startswithr�superrR)r&r�r�r�rr�r�rpr�Z_option_stringsr���	__class__r+r,rR`s&


�zBooleanOptionalAction.__init__cCs$||jvr t||j|�d��dS)Nr�)r��setattrr�r�r�r+r+r,r��s
zBooleanOptionalAction.__call__cCsd�|j�S)Nz | )r%r�r2r+r+r,r��sz"BooleanOptionalAction.format_usage)NNNFNN)N)rr3r4rRr�r��
__classcell__r+r+r�r,r_s� 
rcs(eZdZd�fdd�	Zddd�Z�ZS)	�_StoreActionNFcsT|dkrtd��|dur,|tkr,tdt��tt|�j|||||||||	|
d�
dS)Nrz�nargs 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�)r�rr�r�rRr�r�r+r,rR�s 
�z_StoreAction.__init__cCst||j|�dSr.)r�r�r�r+r+r,r��sz_StoreAction.__call__)NNNNNFNN)N�rr3r4rRr�r�r+r+r�r,r��s�r�cs(eZdZd�fdd�	Zddd�Z�ZS)	�_StoreConstActionNFc	s"tt|�j||d||||d�dS)Nr)r�r�r�r�r�r�rp)r�r�rR�r&r�r�r�r�r�rpr�r�r+r,rR�s
�z_StoreConstAction.__init__cCst||j|j�dSr.)r�r�r�r�r+r+r,r��sz_StoreConstAction.__call__)NFNN)Nr�r+r+r�r,r��s�r�cseZdZd�fdd�	Z�ZS)�_StoreTrueActionFNcs tt|�j||d|||d�dS)NT�r�r�r�r�r�rp)r�rrR�r&r�r�r�r�rpr�r+r,rR�s
�z_StoreTrueAction.__init__)FFN�rr3r4rRr�r+r+r�r,r�s�rcseZdZd�fdd�	Z�ZS)�_StoreFalseActionTFNcs tt|�j||d|||d�dS)NFr)r�rrRrr�r+r,rR�s
�z_StoreFalseAction.__init__)TFNrr+r+r�r,r�s�rcs(eZdZd�fdd�	Zddd�Z�ZS)	�
_AppendActionNFcsT|dkrtd��|dur,|tkr,tdt��tt|�j|||||||||	|
d�
dS)Nrz�nargs for append actions must be != 0; if arg strings are not supplying the value to append, the append const action may be more appropriater�r�)r�rr�rrRr�r�r+r,rR�s 
�z_AppendAction.__init__cCs2t||jd�}t|�}|�|�t||j|�dSr.)r�r�r8r!r��r&r�r�r�r�r1r+r+r,r�s
z_AppendAction.__call__)NNNNNFNN)Nr�r+r+r�r,r�s�rcs(eZdZd�fdd�	Zddd�Z�ZS)	�_AppendConstActionNFc
s$tt|�j||d|||||d�dS)Nr)r�r�r�r�r�r�rpr�)r�rrRr�r�r+r,rRs
�z_AppendConstAction.__init__cCs4t||jd�}t|�}|�|j�t||j|�dSr.)r�r�r8r!r�r�rr+r+r,r�sz_AppendConstAction.__call__)NFNN)Nr�r+r+r�r,r
s�rcs(eZdZd�fdd�	Zddd�Z�ZS)	�_CountActionNFcs tt|�j||d|||d�dS)Nr)r�r�r�r�r�rp)r�rrRrr�r+r,rR's
�z_CountAction.__init__cCs0t||jd�}|durd}t||j|d�dS�NrrT)r�r�r�)r&r�r�r�r��countr+r+r,r�5sz_CountAction.__call__)NFN)Nr�r+r+r�r,r%s
�rcs.eZdZeedf�fdd�	Zddd�Z�ZS)�_HelpActionNcstt|�j|||d|d�dS�Nr)r�r�r�r�rp)r�rrR)r&r�r�r�rpr�r+r,rR>s
�z_HelpAction.__init__cCs|��|��dSr.)�
print_help�exitr�r+r+r,r�Jsz_HelpAction.__call__)N�rr3r4rrRr�r�r+r+r�r,r<s
�rcs0eZdZdeedf�fdd�	Zddd�Z�ZS)�_VersionActionNz&show program's version number and exitcs$tt|�j|||d|d�||_dSr)r�rrR�version)r&r�rr�r�rpr�r+r,rRQs
�z_VersionAction.__init__cCsD|j}|dur|j}|��}|�|�|�|��tj�|��dSr.)r�_get_formatterri�_print_messagerc�_sys�stdoutr)r&r�r�r�r�rrXr+r+r,r�_s
z_VersionAction.__call__)Nrr+r+r�r,rOs�rcsPeZdZGdd�de�Zedddf�fdd�	Zdd�Zd	d
�Zd
dd�Z	�Z
S)�_SubParsersActioncseZdZ�fdd�Z�ZS)z&_SubParsersAction._ChoicesPseudoActioncs@|}}|r|dd�|�7}ttj|�}|jg|||d�dS)Nr�r)r�r�rpr�)r%r�r�_ChoicesPseudoActionrR)r&r)�aliasesrpr�r�Zsupr�r+r,rRms
�z/_SubParsersAction._ChoicesPseudoAction.__init__rr+r+r�r,rksrFNc	s<||_||_i|_g|_tt|�j||t|j|||d�dS)N)r�r�r�r�r�rpr�)�_prog_prefix�
_parser_class�_name_parser_map�_choices_actionsr�rrRr)r&r�rP�parser_classr�r�rpr�r�r+r,rRus	
�z_SubParsersAction.__init__cKs�|�d�dur d|j|f|d<|�dd�}d|vrX|�d�}|�|||�}|j�|�|jfi|��}||j|<|D]}||j|<qv|S)NrPr�rr+rp)r�rr�rrr!rr)r&r)�kwargsrrpZ
choice_actionr��aliasr+r+r,�
add_parser�s

z_SubParsersAction.add_parsercCs|jSr.)rr2r+r+r,r��sz!_SubParsersAction._get_subactionscCs�|d}|dd�}|jtur,t||j|�z|j|}Wn:tyt|d�|j�d�}td�|}t||��Yn0|�|d�\}	}t	|	��
�D]\}
}t||
|�q�|r�t	|��tg�t
|t��|�dS)NrrTr)�parser_namer�z5unknown parser %(parser_name)r (choices: %(choices)s))r�rr�r�KeyErrorr%r�r�parse_known_argsr�r1�
setdefault�_UNRECOGNIZED_ARGS_ATTRr�r�)r&r�r�r�r�r!r'r]�msgZsubnamespace�keyr*r+r+r,r��s$

�	z_SubParsersAction.__call__)N)rr3r4rrrrRr r�r�r�r+r+r�r,ris�rc@seZdZddd�ZdS)�
_ExtendActionNcCs2t||jd�}t|�}|�|�t||j|�dSr.)r�r�r8r�r�rr+r+r,r��s
z_ExtendAction.__call__)N)rr3r4r�r+r+r+r,r(�sr(c@s*eZdZdZddd�Zdd�Zd	d
�ZdS)ra�Factory 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.
    �rr�NcCs||_||_||_||_dSr.)�_mode�_bufsize�	_encoding�_errors)r&�mode�bufsize�encoding�errorsr+r+r,rR�szFileType.__init__c
s�|dkrnd�jvr*d�jvr$tjjStjSt�fdd�dD��rXd�jvrRtjjStjStd��j}t|��zt|�j�j	�j
�j�WSty�}z*||d�}td	�}t
||��WYd}~n
d}~00dS)
N�-r)�bc3s|]}|�jvVqdSr.)r*r�r2r+r,r��r_z$FileType.__call__.<locals>.<genexpr>Zwaxzargument "-" with mode %r)�filename�errorz$can't open '%(filename)s': %(error)s)r*r�stdin�buffer�anyrr�r�r�r+r,r-�OSErrorr)r&�stringr&�er]r�r+r2r,r��s
�
zFileType.__call__cCsT|j|jf}d|jfd|jfg}d�dd�|D�dd�|D��}dt|�j|fS)Nr0r1rcSsg|]}|dkrt|��qS)r�)r")r[r(r+r+r,r^�r_z%FileType.__repr__.<locals>.<listcomp>cSs$g|]\}}|durd||f�qS)Nrr+)r[�kwr(r+r+r,r^s�r)r*r+r,r-r%rr)r&r]rZargs_strr+r+r,r-�s�zFileType.__repr__)r)r�NN)rr3r4r5rRr�r-r+r+r+r,r�s
rc@s(eZdZdZdd�Zdd�Zdd�ZdS)	rz�Simple object for storing attributes.

    Implements equality by attribute names and values, and provides a simple
    string representation.
    cKs|D]}t||||�qdSr.)r�)r&rr)r+r+r,rRszNamespace.__init__cCst|t�stSt|�t|�kSr.)r�r�NotImplementedr�)r&�otherr+r+r,�__eq__s
zNamespace.__eq__cCs
||jvSr.)r0)r&r'r+r+r,�__contains__szNamespace.__contains__N)rr3r4r5rRr?r@r+r+r+r,rsrcs�eZdZ�fdd�Zdd�Zd&dd�Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zd'dd�Zdd�Zd d!�Zd"d#�Zd$d%�Z�ZS)(�_ActionsContainercstt|���||_||_||_||_i|_|�ddt	�|�ddt	�|�ddt
�|�ddt�|�ddt�|�ddt
�|�ddt�|�ddt�|�dd	t�|�dd
t�|�ddt�|�ddt�|��g|_i|_g|_g|_i|_t�d
�|_g|_dS)NrvZstoreZstore_const�
store_trueZstore_falser!Zappend_constr
rpr�parsersr�z^-\d+$|^-\d*\.\d+$)r�rArR�description�argument_default�prefix_chars�conflict_handler�_registries�registerr�r�rrrrrrrrr(�_get_handler�_actions�_option_string_actions�_action_groups�_mutually_exclusive_groups�	_defaultsrKrL�_negative_number_matcher�_has_negative_number_optionals)r&rDrFrErGr�r+r,rRs4z_ActionsContainer.__init__cCs|j�|i�}|||<dSr.)rHr$)r&�
registry_namer*r��registryr+r+r,rISsz_ActionsContainer.registerNcCs|j|�||�Sr.)rHr�)r&rRr*r�r+r+r,�
_registry_getWsz_ActionsContainer._registry_getcKs2|j�|�|jD]}|j|vr||j|_qdSr.)rO�updaterKr�r�)r&rrvr+r+r,�set_defaults]s

z_ActionsContainer.set_defaultscCs8|jD]"}|j|kr|jdur|jSq|j�|d�Sr.)rKr�r�rOr�)r&r�rvr+r+r,�get_defaultfs
z_ActionsContainer.get_defaultcOsP|j}|r&t|�dkrL|dd|vrL|r:d|vr:td��|j|i|��}n|j|i|��}d|vr�|d}||jvr�|j||d<n|jdur�|j|d<|�|�}t|�s�td|f��|fi|��}|�	d|j
|j
�}t|�s�td	|f��|tu�rtd
|f��t|d��rFz|�
��|d�Wnt�yDtd��Yn0|�|�S)
z�
        add_argument(dest, ..., name=value, ...)
        add_argument(option_string, option_string, ..., name=value, ...)
        rTrr�z+dest supplied twice for positional argumentr�Nzunknown action "%s"r�%r is not callablez<%r is a FileType class object, instance of it must be passedrz,length of metavar tuple does not match nargs)rFrtr��_get_positional_kwargs�_get_optional_kwargsrOrE�_pop_action_class�callablerTrrr�rr�r��_add_action)r&r]r�charsr�Zaction_classrv�	type_funcr+r+r,rxps:	 




�z_ActionsContainer.add_argumentcOs&t|g|�Ri|��}|j�|�|Sr.)�_ArgumentGrouprMr!)r&r]rr�r+r+r,�add_argument_group�sz$_ActionsContainer.add_argument_groupcKs t|fi|��}|j�|�|Sr.)�_MutuallyExclusiveGrouprNr!)r&rr�r+r+r,�add_mutually_exclusive_group�sz._ActionsContainer.add_mutually_exclusive_groupcCs`|�|�|j�|�||_|jD]}||j|<q"|jD]"}|j�|�r8|js8|j�d�q8|S)NT)	�_check_conflictrKr!�	containerr�rLrP�matchrQ)r&rvr�r+r+r,r]�s


z_ActionsContainer._add_actioncCs|j�|�dSr.)rK�remover�r+r+r,�_remove_action�sz _ActionsContainer._remove_actioncCs�i}|jD].}|j|vr.td�}t||j��|||j<q
i}|jD]D}|j|vrn|j|j|j|jd�||j<|jD]}||j||<qtqD|jD]&}|j	|j
d�}|jD]}|||<q�q�|jD]}|�||��
|�q�dS)Nz.cannot merge actions - two groups are named %r)�titlerDrG)r�)rMrir�r�rarDrGr�rNrcr�rKr�r])r&reZtitle_group_mapr�r&Z	group_maprv�mutex_groupr+r+r,�_add_container_actions�s0



�

�

z(_ActionsContainer._add_container_actionscKs^d|vrtd�}t|��|�d�ttfvr2d|d<|�d�tkrPd|vrPd|d<t||gd�S)Nr�z1'required' is an invalid argument for positionalsr�Tr��r�r�)r�r�r�rrr�)r&r�rr&r+r+r,rY�sz(_ActionsContainer._get_positional_kwargsc	Os�g}g}|D]`}|d|jvr>||jd�}td�}t||��|�|�t|�dkr|d|jvr|�|�q|�dd�}|dur�|r�|d}n|d}|�|j�}|s�td�}t||��|�dd�}t|||d	�S)
Nr)�optionrFzNinvalid option string %(option)r: must start with a character %(prefix_chars)rrTr�z%dest= is required for options like %rr2r�rl)	rFr�r�r!rtr��lstrip�replacer�)	r&r]rr�Zlong_option_stringsr�r&r�Zdest_option_stringr+r+r,rZ�s.�

z&_ActionsContainer._get_optional_kwargscCs|�d|�}|�d||�S)Nrv)r�rT)r&rr�rvr+r+r,r[sz#_ActionsContainer._pop_action_classcCsDd|j}zt||�WSty>td�}t||j��Yn0dS)Nz_handle_conflict_%sz%invalid conflict_resolution value: %r)rGr�r�r�r�)r&Zhandler_func_namer&r+r+r,rJ#s
z_ActionsContainer._get_handlercCsLg}|jD]&}||jvr
|j|}|�||f�q
|rH|��}|||�dSr.)r�rLr!rJ)r&rvZconfl_optionalsr�Zconfl_optionalrGr+r+r,rd,s


z!_ActionsContainer._check_conflictcCs6tddt|��}d�dd�|D��}t|||��dS)Nzconflicting option string: %szconflicting option strings: %srcSsg|]\}}|�qSr+r+)r[r�rvr+r+r,r^>s�z<_ActionsContainer._handle_conflict_error.<locals>.<listcomp>)rrtr%r)r&rv�conflicting_actionsr�Zconflict_stringr+r+r,�_handle_conflict_error:s�
�z(_ActionsContainer._handle_conflict_errorcCs>|D]4\}}|j�|�|j�|d�|js|j�|�qdSr.)r�rgrLr�rerh)r&rvrpr�r+r+r,�_handle_conflict_resolveCs
z*_ActionsContainer._handle_conflict_resolve)N)N)rr3r4rRrIrTrVrWrxrarcr]rhrkrYrZr[rJrdrqrrr�r+r+r�r,rAs$5
	
3("
		rAcs6eZdZd�fdd�	Z�fdd�Z�fdd�Z�ZS)	r`Ncs�|j}|d|j�|d|j�|d|j�tt|�j}|fd|i|��||_g|_|j	|_	|j
|_
|j|_|j|_|j
|_
|j|_dS)NrGrFrErD)r$rGrFrEr�r`rRrir�rHrKrLrOrQrN)r&rerirDrrUZ
super_initr�r+r,rRTs�z_ArgumentGroup.__init__cs tt|��|�}|j�|�|Sr.)r�r`r]r�r!r�r�r+r,r]jsz_ArgumentGroup._add_actioncs tt|��|�|j�|�dSr.)r�r`rhr�rgr�r�r+r,rhosz_ArgumentGroup._remove_action)NN�rr3r4rRr]rhr�r+r+r�r,r`Rsr`cs.eZdZd�fdd�	Zdd�Zdd�Z�ZS)	rbFcs tt|��|�||_||_dSr.)r�rbrRr��
_container)r&rer�r�r+r,rRvsz _MutuallyExclusiveGroup.__init__cCs2|jrtd�}t|��|j�|�}|j�|�|S)Nz-mutually exclusive arguments must be optional)r�r�r�rtr]r�r!)r&rvr&r+r+r,r]{sz#_MutuallyExclusiveGroup._add_actioncCs|j�|�|j�|�dSr.)rtrhr�rgr�r+r+r,rh�sz&_MutuallyExclusiveGroup._remove_action)Frsr+r+r�r,rbtsrbc
s,eZdZdZddddgedddddddf
�fdd�	Zdd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dAdd�ZdBdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�ZdCd&d'�ZdDd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�ZdEd6d7�ZdFd8d9�ZdGd:d;�ZdHd=d>�Z d?d@�Z!�Z"S)Ira)Object 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
        - exit_on_error -- Determines whether or not ArgumentParser exits with
            error info when an error occurs
    Nr2r5Tc	s&tt|�j}||||	|
d�|dur6tj�tjd�}||_||_	||_
||_||_||_
||_|
|_|j}|td��|_|td��|_d|_dd�}|�dd|�d|vr�dn|d}|j
r�|j|d	|d
ddttd�d
�|D]:}|�|�z
|j}Wnt�yYq�0|j�|�q�dS)N)rDrFrErGrzpositional argumentszoptional argumentscSs|Sr.r+)r:r+r+r,�identity�sz)ArgumentParser.__init__.<locals>.identityrr2�hr9rpzshow this help message and exit)rvr�rp)r�rrR�_os�path�basenamer�argvrPrk�epilog�formatter_class�fromfile_prefix_chars�add_help�allow_abbrev�
exit_on_errorrar��_positionals�
_optionals�_subparsersrIrxrrkrOr�rU)r&rPrkrDr{�parentsr|rFr}rErGr~rr�Z	superinitZ	add_groupruZdefault_prefixrY�defaultsr�r+r,rR�sH��

zArgumentParser.__init__csgd�}�fdd�|D�S)N)rPrkrDr|rGr~csg|]}|t�|�f�qSr+r�r�r2r+r,r^�r_z.ArgumentParser._get_kwargs.<locals>.<listcomp>r+r�r+r2r,r#�szArgumentParser._get_kwargsc	Ks�|jdur|�td��|�dt|��d|vs8d|vrht|�dd��}t|�dd��}|�||�|_n|j|_|�d�dur�|�	�}|�
�}|j}|�|j
||d�|����|d<|�|d�}|fd	gi|��}|j�|�|S)
Nz(cannot have multiple subparser argumentsrrirDZsubcommandsrPr`rCr�)r�r5r�r$rr�rar�r�r�_get_positional_actionsrNrorkrcr|r[r])	r&rrirDrXr�rmZ
parsers_classrvr+r+r,�add_subparsers�s$
zArgumentParser.add_subparserscCs$|jr|j�|�n|j�|�|Sr.)r�r�r]r�r�r+r+r,r]szArgumentParser._add_actioncCsdd�|jD�S)NcSsg|]}|jr|�qSr+r��r[rvr+r+r,r^s�z8ArgumentParser._get_optional_actions.<locals>.<listcomp>�rKr2r+r+r,�_get_optional_actionss�z$ArgumentParser._get_optional_actionscCsdd�|jD�S)NcSsg|]}|js|�qSr+r�r�r+r+r,r^s�z:ArgumentParser._get_positional_actions.<locals>.<listcomp>r�r2r+r+r,r�s�z&ArgumentParser._get_positional_actionscCs4|�||�\}}|r0td�}|�|d�|��|S�Nzunrecognized arguments: %sr)r#r�r5r%�r&r]r�rzr&r+r+r,�
parse_args s
zArgumentParser.parse_argscCs|durtjdd�}nt|�}|dur.t�}|jD]4}|jtur4t||j�s4|jtur4t	||j|j�q4|j
D] }t||�spt	|||j
|�qp|jr�z|�||�\}}Wq�t
y�t��d}|�t|��Yq�0n|�||�\}}t|t��r|�t|t��t|t�||fSrS)rrzr/rrKr�rr�r�r�rOr��_parse_known_argsr�exc_infor5r�r%r�r��delattr)r&r]r�rvr��errr+r+r,r#'s0





zArgumentParser.parse_known_argscs�	jdur�	����i��	jD]R}|j}t|j�D]<\}}��|g�}|�|d|��|�||dd��q2qi�g}t��}	t|	�D]^\}}
|
dkr�|�d�|	D]}
|�d�q�q��	�	|
�}|dur�d}n|�|<d}|�|�q�d�
|��t��t��d�����	fdd�	������	�fd	d
�}
�	�������	�fdd�}g�d
�
��r`t
��}nd}�
|k�r�t�
fdd��D��}�
|k�r�|�
�}|�
k�r�|�
�qdn|�
�
�v�r҈�
|�}��|�|�
|
�
��
�qd|�
�}���|d��g}�	jD]|}|�v�r|j�r(|�t|��nT|jdu�rt|jt��rt�|j��r|jt�|j�u�rt�|j�	�||j���q|�r��	�td�d�
|���	jD]X}|j�r�|jD]}|�v�r��q��q�dd�|jD�}td�}�	�|d�
|���q���fS)NrTr�r2�A�Or`cs|��|���||�}||jurb��|���|g�D]*}|�vr6td�}t|�}t|||��q6|turx|��||�dS)Nznot allowed with argument %s)r��_get_valuesr�r�r�r�rr)rvZargument_stringsr�Zargument_valuesZconflict_actionr&Zaction_name)�action_conflictsr��seen_actions�seen_non_default_actionsr&r+r,�take_action}s


z5ArgumentParser._parse_known_args.<locals>.take_actioncs��|}|\}}}�j}g}|dur:���|�|dS|du�r||d�}�j}|dkr�|d|vr�|�|g|f�|d}	|	|d}|dd�p�d}
�j}||vr�||}|
}ntd�}t|||��nB|dkr�|d}
|g}|�|||f��q\ntd�}t|||��q|d}�|d�}|||�}||}
�||
�}|�|||f��q\q|�sfJ�|D]\}}}�|||��qj|
S)NrTr�rzignored explicit argument %r)�_match_argumentr!rFrLr�r)�start_index�option_tuplervr��explicit_argZmatch_argumentZ
action_tuples�	arg_countr^�charZnew_explicit_argZ
optionals_mapr&�stopr]r�Zselected_patterns)r'�arg_strings_pattern�extras�option_string_indicesr&r�r+r,�consume_optional�sN




z:ArgumentParser._parse_known_args.<locals>.consume_optionalcsn�j}�|d�}|�|�}t�|�D]*\}}�|||�}||7}�||�q&�t|�d��dd�<|Sr.)�_match_arguments_partial�ziprt)r�Z
match_partialZselected_patternZ
arg_countsrvr�r])r'r�r�r&r�r+r,�consume_positionals�s
z=ArgumentParser._parse_known_args.<locals>.consume_positionalsrr�csg|]}|�kr|�qSr+r+)r[r�)r�r+r,r^�s�z4ArgumentParser._parse_known_args.<locals>.<listcomp>z(the following arguments are required: %srcSsg|]}|jturt|��qSr+)rprr�r�r+r+r,r^;s
�z#one of the arguments %s is requiredr)N)r}�_read_args_from_filesrNr�r�r$r��iterr!�_parse_optionalr%r�r�rBrArKr�r�r�r�r�r�r�r�r��
_get_valuer5r�)r&r'r�rjr�r�Zmutex_actionZ	conflictsZarg_string_pattern_partsZarg_strings_iter�
arg_stringr��patternr�r�Zmax_option_string_indexZnext_option_string_indexZpositionals_end_indexZstringsZ
stop_indexZrequired_actionsrvr�r�r&r+)r�r'r�r�r�r�r�r�r�r&r�r�r,r�Ns�





J

�






�
���
�



�z ArgumentParser._parse_known_argsc	Cs�g}|D]�}|r|d|jvr*|�|�qzxt|dd���T}g}|����D]}|�|�D]}|�|�q\qN|�|�}|�|�Wd�n1s�0YWqty�t	�
�d}|�t|��Yq0q|Sr	)
r}r!r��readr��convert_arg_line_to_argsr�r�r9rr�r5r�)r&r'Znew_arg_stringsr�Z	args_file�arg_liner(r�r+r+r,r�Ds 
,z$ArgumentParser._read_args_from_filescCs|gSr.r+)r&r�r+r+r,r�^sz'ArgumentParser.convert_arg_line_to_argscCsz|�|�}t�||�}|durldtd�ttd�ttd�i}|�|j�}|durbtdd|j�|j}t	||��t
|�d��S)Nzexpected one argumentzexpected at most one argumentzexpected at least one argumentzexpected %s argumentzexpected %s argumentsrT)�_get_nargs_patternrKrfr�rr
r�r�rrrtr�)r&rvr��
nargs_patternrfZnargs_errorsr&r+r+r,r�as"
���
zArgumentParser._match_argumentcsrg}tt|�dd�D]X}|d|�}d��fdd�|D��}t�||�}|dur|�dd�|��D��qnq|S)Nrr�r`csg|]}��|��qSr+)r�r�r2r+r,r^}s�z;ArgumentParser._match_arguments_partial.<locals>.<listcomp>cSsg|]}t|��qSr+)rt)r[r:r+r+r,r^�r_)r�rtr%rKrfr�rm)r&rlr�r�r�Z
actions_slicer�rfr+r2r,r�ws�z'ArgumentParser._match_arguments_partialc
Cs|sdS|d|jvrdS||jvr8|j|}||dfSt|�dkrHdSd|vr~|�dd�\}}||jvr~|j|}|||fS|�|�}t|�dkr�d�dd�|D��}||d�}td�}|�||�nt|�dkr�|\}	|	S|j�	|�r�|j
s�dSd	|v�rdSd|dfS)
NrrT�=rcSsg|]\}}}|�qSr+r+)r[rvr�r�r+r+r,r^�s�z2ArgumentParser._parse_optional.<locals>.<listcomp>)rmZmatchesz4ambiguous option: %(option)s could match %(matches)sr)rFrLrt�split�_get_option_tuplesr%r�r5rPrfrQ)
r&r�rvr�r�Z
option_tuplesZoptionsr]r&r�r+r+r,r��s>







�

zArgumentParser._parse_optionalc
Cs0g}|j}|d|vr�|d|vr�|jr~d|vrB|�dd�\}}n|}d}|jD],}|�|�rP|j|}|||f}|�|�qPn�|d|v�r|d|v�r|}d}|dd�}|dd�}	|jD]T}||kr�|j|}|||	f}|�|�q�|�|�r�|j|}|||f}|�|�q�n|�td�|�|S)NrrTr�r9zunexpected option string: %s)rFrr�rLr�r!r5r�)
r&r�r�r^Z
option_prefixr�rvr�Zshort_option_prefixZshort_explicit_argr+r+r,r��s:









z!ArgumentParser._get_option_tuplescCs�|j}|durd}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-*r�r`r2)
r�rrr
rrrr%r�ro)r&rvr�r�r+r+r,r��s(z!ArgumentParser._get_nargs_patterncCs4|�||�\}}|r0td�}|�|d�|��|Sr�)�parse_known_intermixed_argsr�r5r%r�r+r+r,�parse_intermixed_args	s
z$ArgumentParser.parse_intermixed_argsc	s�|���dd��D�}|r,td|dj���fdd�|jD�rHtd���z�|j}z�|jdurp|��dd�|_�D] }|j|_t|_|j|_	t|_qt|�
||�\}}�D]J}t||j�r�t
||j�gkr�ddlm}|d	|j|f�t||j�q�W�D]}|j|_|j	|_q�n�D]}|j|_|j	|_�q0|��}zt|D]}|j|_d
|_�q@|jD]}	|	j|	_d
|	_�q\|�
||�\}}
W|D]}|j|_�q�|jD]}	|	j|	_�q�n,|D]}|j|_�q�|jD]}	|	j|	_�q�0W||_n||_0||
fS)NcSsg|]}|jttfvr|�qSr+)r�rrr�r+r+r,r^4	s�z>ArgumentParser.parse_known_intermixed_args.<locals>.<listcomp>z3parse_intermixed_args: positional arg with nargs=%srcs&g|]}|jD]}|�vr|j�qqSr+)r�r�)r[r�rv�r�r+r,r^:	s�z;parse_intermixed_args: positional in mutuallyExclusiveGroup�)�warnzDo not expect %s in %sF)r�r�r�rNrkr�Z
save_nargsrr�Zsave_defaultr#r�r�r��warningsr�r�r�r�Z
save_required)r&r]r��aZ
save_usagervZremaining_argsr�r�r�r�r+r�r,r�&	sn
�
���


�

�
z*ArgumentParser.parse_known_intermixed_argscs��jttfvr0z|�d�Wnty.Yn0|sx�jtkrx�jrL�j}n�j}t	|t
�rt���|�}���|��n|s��jt
kr��js��jdur��j}n|}���|�n�t|�dkr�jdtfvr�|\}���|�}���|�n��jtk�r��fdd�|D�}np�jtk�r>��fdd�|D�}���|d�n>�jtk�rPt}n,��fdd�|D�}|D]}���|��qh|S)Nr�rTcsg|]}���|��qSr+�r��r[�v�rvr&r+r,r^�	r_z.ArgumentParser._get_values.<locals>.<listcomp>csg|]}���|��qSr+r�r�r�r+r,r^�	r_rcsg|]}���|��qSr+r�r�r�r+r,r^�	r_)r�rrrgr�rr�r�r�r�r�r��_check_valuerrtr)r&rvr'r*r�r�r+r�r,r�s	sD
�
zArgumentParser._get_valuesc	Cs�|�d|j|j�}t|�s0td�}t|||��z||�}Wn�ty|t|jdt|j��}tt	�
�d�}t||��YnJttfy�t|jdt|j��}||d�}td�}t|||��Yn0|S)NrrXrrT)rr*z!invalid %(type)s value: %(value)r)
rTrr\r�rrr�r"r�rr�r�r�)r&rvr�r_r&r�r)r]r+r+r,r��	s 
zArgumentParser._get_valuecCsF|jdurB||jvrB|d�tt|j��d�}td�}t|||��dS)Nr)r*r�z3invalid choice: %(value)r (choose from %(choices)s))r�r%rsr"r�r)r&rvr*r]r&r+r+r,r��	s�zArgumentParser._check_valuecCs$|��}|�|j|j|j�|��Sr.)rrorkrKrNrc)r&rXr+r+r,r��	s
�zArgumentParser.format_usagecCst|��}|�|j|j|j�|�|j�|jD]0}|�|j	�|�|j�|�
|j�|��q.|�|j
�|��Sr.)rrorkrKrNrirDrMreriryr�rfr{rc)r&rXZaction_groupr+r+r,rc�	s�

zArgumentParser.format_helpcCs|j|jd�S)Nr~)r|rPr2r+r+r,r�	szArgumentParser._get_formattercCs"|durtj}|�|��|�dSr.)rrrr��r&�filer+r+r,�print_usage�	szArgumentParser.print_usagecCs"|durtj}|�|��|�dSr.)rrrrcr�r+r+r,r
�	szArgumentParser.print_helpcCs |r|durtj}|�|�dSr.)r�stderr�write)r&r�r�r+r+r,r�	szArgumentParser._print_messagercCs |r|�|tj�t�|�dSr.)rrr�r)r&Zstatusr�r+r+r,r
szArgumentParser.exitcCs0|�tj�|j|d�}|�dtd�|�dS)z�error(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.
        )rPr�r9z%(prog)s: error: %(message)s
N)r�rr�rPrr�)r&r�r]r+r+r,r5
s	zArgumentParser.error)NN)NN)NN)NN)N)N)N)rN)#rr3r4r5rrRr#r�r]r�r�r�r#r�r�r�r�r�r�r�r�r�r�r�r�r�r�rcrr�r
rrr5r�r+r+r�r,r�sX�B

'w:-1

M8


	
r)2r5�__version__�__all__�osrw�rerK�sysrrr�rrrrr
rrr%r�rr8rrr	rr
r��	Exceptionrrrrr�r�rrrrrrrrr(rrrAr`rbrr+r+r+r,�<module>s`=	^)#&]78"

Zerion Mini Shell 1.0