Your IP : 3.149.254.229


Current Path : /lib64/python3.8/__pycache__/
Upload File :
Current File : //lib64/python3.8/__pycache__/argparse.cpython-38.opt-2.pyc

U

e5dw�@s,dZddddddddd	d
ddd
ddddgZddlZddlZddlZddlZ	ddl
m
ZmZdZ
dZdZdZdZdZdZGdd�de�Zdd�ZGd d�de�ZGd!d�de�ZGd"d�de�ZGd#d�de�ZGd$d	�d	e�Zd%d&�ZGd'd�de�ZGd(d�de�ZGd)d�de�Z Gd*d+�d+e �Z!Gd,d-�d-e �Z"Gd.d/�d/e"�Z#Gd0d1�d1e"�Z$Gd2d3�d3e �Z%Gd4d5�d5e �Z&Gd6d7�d7e �Z'Gd8d9�d9e �Z(Gd:d;�d;e �Z)Gd<d=�d=e �Z*Gd>d?�d?e%�Z+Gd@d�de�Z,GdAd
�d
e�Z-GdBdC�dCe�Z.GdDdE�dEe.�Z/GdFdG�dGe/�Z0GdHd�dee.�Z1dS)Iz1.1�ArgumentParser�
ArgumentError�ArgumentTypeError�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$eZdZdd�Zdd�Zdd�ZdS)�_AttributeHoldercCs�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*� /usr/lib64/python3.8/argparse.py�__repr__ts

z_AttributeHolder.__repr__cCst|j���S�N)�sorted�__dict__�items�r%r*r*r+r"�sz_AttributeHolder._get_kwargscCsgSr-r*r1r*r*r+r�sz_AttributeHolder._get_argsN)r�
__module__�__qualname__r,r"rr*r*r*r+rks	rcCs6|dkrgSt|�tkr$|dd�Sddl}|�|�S)Nr)r�list�copy)r0r5r*r*r+�_copy_items�sr6c@s�eZdZd:dd�Zdd�Zdd	�ZGd
d�de�Zdd
�Zdd�Z	dd�Z
dd�Zd;dd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�Zd4d5�Zd6d7�Zd8d9�ZdS)<r��NcCs�|dkrt��j}|d8}||_||_t|t|d|d��|_||_d|_	d|_
d|_|�|d�|_
|j
|_t�dtj�|_t�d�|_dS)Nr7�rz\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+�__init__�s 
�zHelpFormatter.__init__cCs"|j|j7_|jd7_dS�N��rCr>rDr1r*r*r+�_indent�szHelpFormatter._indentcCs"|j|j8_|jd8_dSrQrSr1r*r*r+�_dedent�szHelpFormatter._dedentc@seZdZddd�Zdd�ZdS)zHelpFormatter._SectionNcCs||_||_||_g|_dSr-)�	formatter�parent�headingr0)r%rVrWrXr*r*r+rP�szHelpFormatter._Section.__init__cCs�|jdk	r|j��|jj}|dd�|jD��}|jdk	rD|j��|sLdS|jtk	rz|jdk	rz|jj}d|d|jf}nd}|d||dg�S)NcSsg|]\}}||��qSr*r*)�.0�func�argsr*r*r+�
<listcomp>�sz6HelpFormatter._Section.format_help.<locals>.<listcomp>�z%*s%s:
�
)	rWrVrT�_join_partsr0rUrXrrC)r%r$Z	item_helpZcurrent_indentrXr*r*r+�format_help�s



z"HelpFormatter._Section.format_help)N)rr2r3rPr`r*r*r*r+rF�s
rFcCs|jj�||f�dSr-)rHr0r )r%rZr[r*r*r+�	_add_item�szHelpFormatter._add_itemcCs0|��|�||j|�}|�|jg�||_dSr-)rTrFrHrar`)r%rXZsectionr*r*r+�
start_section�szHelpFormatter.start_sectioncCs|jj|_|��dSr-)rHrWrUr1r*r*r+�end_section�s
zHelpFormatter.end_sectioncCs$|tk	r |dk	r |�|j|g�dSr-)rra�_format_text)r%�textr*r*r+�add_text�szHelpFormatter.add_textcCs&|tk	r"||||f}|�|j|�dSr-)rra�
_format_usage)r%�usage�actions�groups�prefixr[r*r*r+�	add_usage�szHelpFormatter.add_usagecCsv|jtk	rr|j}||�g}|�|�D]}|�||��q$tdd�|D��}||j}t|j|�|_|�|j	|g�dS)NcSsg|]}t|��qSr*��len�rY�sr*r*r+r\
sz.HelpFormatter.add_argument.<locals>.<listcomp>)
�helpr�_format_action_invocation�_iter_indented_subactionsr r@rCrEra�_format_action)r%�actionZget_invocationZinvocations�	subactionZinvocation_lengthZ
action_lengthr*r*r+�add_arguments


�zHelpFormatter.add_argumentcCs|D]}|�|�qdSr-)rw)r%rirur*r*r+�
add_argumentsszHelpFormatter.add_argumentscCs.|j��}|r*|j�d|�}|�d�d}|S)N�

r^)rGr`rM�sub�strip)r%rqr*r*r+r`s

zHelpFormatter.format_helpcCsd�dd�|D��S)Nr]cSsg|]}|r|tk	r|�qSr*)r)rY�partr*r*r+r\!s�z-HelpFormatter._join_parts.<locals>.<listcomp>)r$)r%Zpart_stringsr*r*r+r_ s
�zHelpFormatter._join_partscs|dkrtd�}|dk	r,|t|jd�}�n�|dkrL|sLdt|jd�}�n�|dk�rdt|jd�}g}g}|D] }|jr�|�|�qr|�|�qr|j}	|	|||�}
d�dd�||
fD��}|j|j�t	|�t	|��k�rd}|	||�}|	||�}
t
�||�}t
�||
�}d�fdd	�	}t	|�t	|�d
�k�r�dt	|�t	|�d}|�r|||g|||�}|�|||��n |�r�||g|||�}n|g}nZdt	|�}||}|||�}t	|�dk�r�g}|�|||��|�|||��|g|}d�|�}d
||fS)Nzusage: �rNz%(prog)s� cSsg|]}|r|�qSr*r*ror*r*r+r\Asz/HelpFormatter._format_usage.<locals>.<listcomp>z%\(.*?\)+(?=\s|$)|\[.*?\]+(?=\s|$)|\S+cs�g}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)NrRr~r)rnr r$)�parts�indentrk�lines�lineZline_lenr|��
text_widthr*r+�	get_linesUs"
z.HelpFormatter._format_usage.<locals>.get_linesg�?rRr^z%s%s

)N)
�_�dictr=�option_stringsr �_format_actions_usager$rBrCrnrI�findall�extend)r%rhrirjrkrN�	optionals�positionalsru�formatZaction_usageZpart_regexpZ	opt_usageZ	pos_usageZ	opt_partsZ	pos_partsr�r�r�rr*r�r+rg%sX
�




zHelpFormatter._format_usagec	Cs�t�}i}|D�]}z|�|jd�}Wntk
r@YqYqX|t|j�}|||�|jkr|jD]}|�|�qh|js�||kr�||d7<nd||<||kr�||d7<nd||<nF||kr�||d7<nd||<||k�r||d7<nd||<t|d|�D]}	d	||	<�qqg}
t|�D�]"\}	}|j	t
k�r�|
�d�|�|	�d	k�rr|�
|	�n"|�|	d�d	k�rX|�
|	d�n�|j�s�|�|�}|�||�}||k�r�|ddk�r�|d
dk�r�|dd
�}|
�|�nf|jd}
|jdk�rd|
}n"|�|�}|�||�}d|
|f}|j�sN||k�rNd
|}|
�|��q6t|dd�D]}	||	g|
|	|	�<�qhd�dd�|
D��}d}d}t�d|d|�}t�d|d|�}t�d||fd|�}t�dd|�}|��}|S)Nrz [�[�]z (�(�)rR�|����%s�%s %s�[%s]T)�reverser~cSsg|]}|dk	r|�qSr-r*)rY�itemr*r*r+r\�sz7HelpFormatter._format_actions_usage.<locals>.<listcomp>z[\[(]z[\])]z(%s) z\1� (%s)z%s *%sr]z\(([^|]*)\))�set�index�_group_actions�
ValueErrorrn�add�required�range�	enumeraterqrr �get�popr��#_get_default_metavar_for_positional�_format_args�nargs�!_get_default_metavar_for_optionalr.r$rIrzr{)r%rirj�
group_actionsZinserts�group�start�endru�ir�defaultr|�
option_string�args_stringre�open�closer*r*r+r��sz










z#HelpFormatter._format_actions_usagecCsFd|kr|t|jd�}t|j|jd�}d|j}|�|||�dS)Nz%(prog)r}�r~ry)r�r=r@rBrC�
_fill_text)r%rer�r�r*r*r+rd�s

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�|
dd�D]}|�d|d|f�q�n|�d��s|�d�|�
|�D]}|�|�|���q|�|�S)	Nr7r�r]z%*s%s
z	%*s%-*s  rrRr^)r?rErAr@rBrCrrrqrn�_expand_help�_split_linesr �endswithrsrtr_)
r%ruZ
help_positionZ
help_widthZaction_widthZ
action_header�tupZindent_firstrZ	help_textZ
help_linesr�rvr*r*r+rt�s8
�



zHelpFormatter._format_actioncCs�|js&|�|�}|�||�d�\}|Sg}|jdkrB|�|j�n4|�|�}|�||�}|jD]}|�d||f�q^d�|�SdS)NrRrr�r)	r�r��_metavar_formatterr�r�r�r�r r$)r%rur��metavarrr�r�r*r*r+rr"s



z'HelpFormatter._format_action_invocationcsP|jdk	r|j�n.|jdk	r<dd�|jD�}dd�|��n|��fdd�}|S)NcSsg|]}t|��qSr*��str)rYZchoicer*r*r+r\>sz4HelpFormatter._metavar_formatter.<locals>.<listcomp>z{%s}�,cst�t�r�S�f|SdSr-)�
isinstance�tuple)Z
tuple_size��resultr*r+r�Cs
z0HelpFormatter._metavar_formatter.<locals>.format)r��choicesr$)r%ru�default_metavarZchoice_strsr�r*r�r+r�:s

z HelpFormatter._metavar_formattercCs�|�||�}|jdkr$d|d�}n�|jtkr<d|d�}n�|jtkrTd|d�}n�|jtkrld|d�}n�|jtkr|d}nt|jtkr�d|d�}n\|jtkr�d	}nLzd
d�t|j�D�}Wnt	k
r�t
d�d�YnXd
�|�||j�}|S)Nr�rRr�z
[%s [%s ...]]r7z%s [%s ...]rz%s ...r]cSsg|]}d�qS)r�r*)rYr�r*r*r+r\\sz.HelpFormatter._format_args.<locals>.<listcomp>zinvalid nargs valuer~)r�r�r
rrrrrr��	TypeErrorr�r$)r%rur�Zget_metavarr�Zformatsr*r*r+r�Js*






zHelpFormatter._format_argscCs�tt|�|jd�}t|�D]}||tkr||=qt|�D] }t||d�r:||j||<q:|�d�dk	r�d�dd�|dD��}||d<|�	|�|S)Nr}rr�rcSsg|]}t|��qSr*r�)rY�cr*r*r+r\ksz.HelpFormatter._expand_help.<locals>.<listcomp>)
r��varsr=r4r�hasattrrr�r$�_get_help_string)r%ruZparamsr(Zchoices_strr*r*r+r�bszHelpFormatter._expand_helpccs@z
|j}Wntk
rYnX|��|�EdH|��dSr-)�_get_subactions�AttributeErrorrTrU)r%ruZget_subactionsr*r*r+rsos
z'HelpFormatter._iter_indented_subactionscCs&|j�d|���}ddl}|�||�S)Nr~r)rLrzr{�textwrapZwrap)r%rerOr�r*r*r+r�yszHelpFormatter._split_linescCs,|j�d|���}ddl}|j||||d�S)Nr~r)Zinitial_indentZsubsequent_indent)rLrzr{r�Zfill)r%rerOr�r�r*r*r+r��s�zHelpFormatter._fill_textcCs|jSr-)rq�r%rur*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)r7r8N)N)rr2r3rPrTrU�objectrFrarbrcrfrlrwrxr`r_rgr�rdrtrrr�r�r�rsr�r�r�r�r�r*r*r*r+r�s<	�

`g/

c@seZdZdd�ZdS)rcs d��fdd�|jdd�D��S)Nr]c3s|]}�|VqdSr-r*)rYr��r�r*r+�	<genexpr>�sz9RawDescriptionHelpFormatter._fill_text.<locals>.<genexpr>T)�keepends)r$�
splitlines)r%rerOr�r*r�r+r��sz&RawDescriptionHelpFormatter._fill_textN)rr2r3r�r*r*r*r+r�sc@seZdZdd�ZdS)rcCs|��Sr-)r�)r%rerOr*r*r+r��sz!RawTextHelpFormatter._split_linesN)rr2r3r�r*r*r*r+r�sc@seZdZdd�ZdS)rcCs>|j}d|jkr:|jtk	r:ttg}|js2|j|kr:|d7}|S)Nz
%(default)z (default: %(default)s))rqr�rr
rr�r�)r%rurqZdefaulting_nargsr*r*r+r��s

z.ArgumentDefaultsHelpFormatter._get_help_stringN)rr2r3r�r*r*r*r+r�sc@seZdZdd�Zdd�ZdS)r	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)rr2r3r�r�r*r*r*r+r	�scCsN|dkrdS|jrd�|j�S|jdtfkr2|jS|jdtfkrF|jSdSdS)N�/)r�r$r�rr�)�argumentr*r*r+�_get_action_name�sr�c@seZdZdd�Zdd�ZdS)rcCst|�|_||_dSr-)r��
argument_name�message)r%r�r�r*r*r+rP�s
zArgumentError.__init__cCs(|jdkrd}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)rr2r3rPr�r*r*r*r+r�sc@seZdZdS)rN)rr2r3r*r*r*r+r�sc@s(eZdZd	dd�Zdd�Zd
dd�ZdS)rNFcCs@||_||_||_||_||_||_||_||_|	|_|
|_	dSr-�
r�r�r��constr�rr�r�rqr��r%r�r�r�r�r�rr�r�rqr�r*r*r+rP)szAction.__init__c	s(ddddddddd	g	}�fd
d�|D�S)Nr�r�r�r�r�rr�rqr�csg|]}|t�|�f�qSr*��getattr�rYr(r1r*r+r\Ksz&Action._get_kwargs.<locals>.<listcomp>r*�r%�namesr*r1r+r"?s�zAction._get_kwargscCsttd���dS)Nz.__call__() not defined)�NotImplementedErrorr��r%�parser�	namespace�valuesr�r*r*r+�__call__MszAction.__call__)NNNNNFNN)N)rr2r3rPr"r�r*r*r*r+r�s6�
cs(eZdZd�fdd�	Zddd�Z�ZS)	�_StoreActionNFcsT|dkrtd��|dk	r,|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�r
�superr�rPr���	__class__r*r+rPSs 
�z_StoreAction.__init__cCst||j|�dSr-)�setattrr�r�r*r*r+r�psz_StoreAction.__call__)NNNNNFNN)N�rr2r3rPr��
__classcell__r*r*r�r+r�Qs�r�cs(eZdZd�fdd�	Zddd�Z�ZS)	�_StoreConstActionNFc	s"tt|�j||d||||d�dS)Nr)r�r�r�r�r�r�rq)r�r�rP�r%r�r�r�r�r�rqr�r�r*r+rPvs
�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�ts�r�cseZdZd�fdd�	Z�ZS)�_StoreTrueActionFNcs tt|�j||d|||d�dS)NT�r�r�r�r�r�rq)r�r�rP�r%r�r�r�r�rqr�r*r+rP�s
�z_StoreTrueAction.__init__)FFN�rr2r3rPr�r*r*r�r+r��s�r�cseZdZd�fdd�	Z�ZS)�_StoreFalseActionTFNcs tt|�j||d|||d�dS)NFr�)r�r�rPr�r�r*r+rP�s
�z_StoreFalseAction.__init__)TFNr�r*r*r�r+r��s�r�cs(eZdZd�fdd�	Zddd�Z�ZS)	�
_AppendActionNFcsT|dkrtd��|dk	r,|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�r
r�r�rPr�r�r*r+rP�s 
�z_AppendAction.__init__cCs2t||jd�}t|�}|�|�t||j|�dSr-)r�r�r6r r��r%r�r�r�r�r0r*r*r+r��s
z_AppendAction.__call__)NNNNNFNN)Nr�r*r*r�r+r��s�r�cs(eZdZd�fdd�	Zddd�Z�ZS)	�_AppendConstActionNFc
s$tt|�j||d|||||d�dS)Nr)r�r�r�r�r�r�rqr�)r�r�rPr�r�r*r+rP�s
�z_AppendConstAction.__init__cCs4t||jd�}t|�}|�|j�t||j|�dSr-)r�r�r6r r�r�r�r*r*r+r��sz_AppendConstAction.__call__)NFNN)Nr�r*r*r�r+r��s�r�cs(eZdZd�fdd�	Zddd�Z�ZS)	�_CountActionNFcs tt|�j||d|||d�dS)Nr)r�r�r�r�r�rq)r�r�rPr�r�r*r+rP�s
�z_CountAction.__init__cCs0t||jd�}|dkrd}t||j|d�dS�NrrR)r�r�r�)r%r�r�r�r��countr*r*r+r��sz_CountAction.__call__)NFN)Nr�r*r*r�r+r��s
�r�cs.eZdZeedf�fdd�	Zddd�Z�ZS)�_HelpActionNcstt|�j|||d|d�dS�Nr)r�r�r�r�rq)r�r�rP)r%r�r�r�rqr�r*r+rPs
�z_HelpAction.__init__cCs|��|��dSr-)�
print_help�exitr�r*r*r+r�sz_HelpAction.__call__)N�rr2r3rrPr�r�r*r*r�r+r�s
�r�cs0eZdZdeedf�fdd�	Zddd�Z�ZS)�_VersionActionNz&show program's version number and exitcs$tt|�j|||d|d�||_dSr�)r�rrP�version)r%r�rr�r�rqr�r*r+rPs
�z_VersionAction.__init__cCsD|j}|dkr|j}|��}|�|�|�|��tj�|��dSr-)r�_get_formatterrf�_print_messager`�_sys�stdoutr)r%r�r�r�r�rrVr*r*r+r�(s
z_VersionAction.__call__)Nrr*r*r�r+rs�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�rqr�)r$r�r	�_ChoicesPseudoActionrP)r%r(�aliasesrqr�r�Zsupr�r*r+rP6s
�z/_SubParsersAction._ChoicesPseudoAction.__init__r�r*r*r�r+r
4sr
FNc	s<||_||_i|_g|_tt|�j||t|j|||d�dS)N)r�r�r�r�r�rqr�)�_prog_prefix�
_parser_class�_name_parser_map�_choices_actionsr�r	rPr)r%r�rN�parser_classr�r�rqr�r�r*r+rP>s	
�z_SubParsersAction.__init__cKs�|�d�dkr d|j|f|d<|�dd�}d|krX|�d�}|�|||�}|j�|�|jf|�}||j|<|D]}||j|<qr|S)NrNr�rr*rq)r�rr�r
rr r
r)r%r(�kwargsrrqZ
choice_actionr��aliasr*r*r+�
add_parserUs

z_SubParsersAction.add_parsercCs|jSr-)rr1r*r*r+r�lsz!_SubParsersAction._get_subactionscCs�|d}|dd�}|jtk	r,t||j|�z|j|}Wn<tk
rv|d�|j�d�}td�|}t||��YnX|�|d�\}	}t	|	��
�D]\}
}t||
|�q�|r�t	|��tg�t
|t��|�dS)NrrRr)�parser_namer�z5unknown parser %(parser_name)r (choices: %(choices)s))r�rr�r�KeyErrorr$r�r�parse_known_argsr�r0�
setdefault�_UNRECOGNIZED_ARGS_ATTRr�r�)r%r�r�r�r�rr&r[�msgZsubnamespace�keyr)r*r*r+r�os$

�	z_SubParsersAction.__call__)N)rr2r3rr
rrPrr�r�r�r*r*r�r+r	2s�r	c@seZdZddd�ZdS)�
_ExtendActionNcCs2t||jd�}t|�}|�|�t||j|�dSr-)r�r�r6r�r�r�r*r*r+r��s
z_ExtendAction.__call__)N)rr2r3r�r*r*r*r+r�src@s&eZdZd
dd�Zdd�Zdd	�ZdS)r�rr�NcCs||_||_||_||_dSr-)�_mode�_bufsize�	_encoding�_errors)r%�mode�bufsize�encoding�errorsr*r*r+rP�szFileType.__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�-r�wzargument "-" with mode %r)�filename�errorz$can't open '%(filename)s': %(error)s)rr�stdinrr�r�r�rrr �OSErrorr)r%�stringr�er[r�r*r*r+r��s

�
zFileType.__call__cCsT|j|jf}d|jfd|jfg}d�dd�|D�dd�|D��}dt|�j|fS)Nr#r$rcSsg|]}|dkrt|��qS)r�)r!)rYr'r*r*r+r\�sz%FileType.__repr__.<locals>.<listcomp>cSs$g|]\}}|dk	rd||f�qS)Nrr*)rY�kwr'r*r*r+r\�s�r)rrrr r$rr)r%r[rZargs_strr*r*r+r,�s�zFileType.__repr__)rr�NN)rr2r3rPr�r,r*r*r*r+r�s
c@s$eZdZdd�Zdd�Zdd�ZdS)r
cKs|D]}t||||�qdSr-)r�)r%rr(r*r*r+rP�szNamespace.__init__cCst|t�stSt|�t|�kSr-)r�r
�NotImplementedr�)r%�otherr*r*r+�__eq__�s
zNamespace.__eq__cCs
||jkSr-)r/)r%rr*r*r+�__contains__�szNamespace.__contains__N)rr2r3rPr0r1r*r*r*r+r
�scs�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)NruZstoreZstore_const�
store_trueZstore_falser Zappend_constr�rqr�parsersr�z^-\d+$|^-\d*\.\d+$)r�r2rP�description�argument_default�prefix_chars�conflict_handler�_registries�registerr�r�r�r�r�r�r�r�rr	r�_get_handler�_actions�_option_string_actions�_action_groups�_mutually_exclusive_groups�	_defaultsrIrJ�_negative_number_matcher�_has_negative_number_optionals)r%r5r7r6r8r�r*r+rP�s4z_ActionsContainer.__init__cCs|j�|i�}|||<dSr-)r9r)r%�
registry_namer)r��registryr*r*r+r:sz_ActionsContainer.registerNcCs|j|�||�Sr-)r9r�)r%rCr)r�r*r*r+�
_registry_get sz_ActionsContainer._registry_getcKs2|j�|�|jD]}|j|kr||j|_qdSr-)r@�updater<r�r�)r%rrur*r*r+�set_defaults&s

z_ActionsContainer.set_defaultscCs8|jD]"}|j|kr|jdk	r|jSq|j�|d�Sr-)r<r�r�r@r�)r%r�rur*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|�s�td|f��|f|�}|�	d|j
|j
�}t|�s�td|f��|tkr�td	|f��t|d
��r:z|�
��|d�Wntk
�r8td��YnX|�|�S)NrRrr�z+dest supplied twice for positional argumentr�zunknown 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)r7rnr��_get_positional_kwargs�_get_optional_kwargsr@r6�_pop_action_class�callablerErrr�rr�r��_add_action)r%r[r�charsr�Zaction_classru�	type_funcr*r*r+rw9s:	 




�z_ActionsContainer.add_argumentcOs t|f|�|�}|j�|�|Sr-)�_ArgumentGroupr>r )r%r[rr�r*r*r+�add_argument_grouplsz$_ActionsContainer.add_argument_groupcKst|f|�}|j�|�|Sr-)�_MutuallyExclusiveGroupr?r )r%rr�r*r*r+�add_mutually_exclusive_groupqsz._ActionsContainer.add_mutually_exclusive_groupcCs`|�|�|j�|�||_|jD]}||j|<q"|jD]"}|j�|�r8|js8|j�d�q8|S)NT)	�_check_conflictr<r �	containerr�r=rA�matchrB)r%rur�r*r*r+rNvs


z_ActionsContainer._add_actioncCs|j�|�dSr-)r<�remover�r*r*r+�_remove_action�sz _ActionsContainer._remove_actioncCs�i}|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]}|||<q�q�|jD]}|�||��
|�q�dS)Nz.cannot merge actions - two groups are named %r)�titler5r8)r�)r>rZr�r�rRr5r8r�r?rTr�r<r�rN)r%rVZtitle_group_mapr�rZ	group_mapru�mutex_groupr*r*r+�_add_container_actions�s0



�

�

z(_ActionsContainer._add_container_actionscKs^d|krtd�}t|��|�d�ttfkr2d|d<|�d�tkrPd|krPd|d<t||gd�S)Nr�z1'required' is an invalid argument for positionalsr�Tr��r�r�)r�r�r�r
rr�)r%r�rrr*r*r+rJ�sz(_ActionsContainer._get_positional_kwargsc	Os�g}g}|D]n}|d|jkr>||jd�}td�}t||��|�|�|d|jkrt|�dkr|d|jkr|�|�q|�dd�}|dkr�|r�|d}n|d}|�|j�}|s�td�}t||��|�dd�}t|||d	�S)
Nr)�optionr7zNinvalid option string %(option)r: must start with a character %(prefix_chars)rrRr�z%dest= is required for options like %rr%r�r])	r7r�r�r rnr��lstrip�replacer�)	r%r[rr�Zlong_option_stringsr�rr�Zdest_option_stringr*r*r+rK�s2�

z&_ActionsContainer._get_optional_kwargscCs|�d|�}|�d||�S)Nru)r�rE)r%rr�rur*r*r+rL�sz#_ActionsContainer._pop_action_classcCsFd|j}zt||�WStk
r@td�}t||j��YnXdS)Nz_handle_conflict_%sz%invalid conflict_resolution value: %r)r8r�r�r�r�)r%Zhandler_func_namerr*r*r+r;�s
z_ActionsContainer._get_handlercCsLg}|jD]&}||jkr
|j|}|�||f�q
|rH|��}|||�dSr-)r�r=r r;)r%ruZconfl_optionalsr�Zconfl_optionalr8r*r*r+rU�s


z!_ActionsContainer._check_conflictcCs6tddt|��}d�dd�|D��}t|||��dS)Nzconflicting option string: %szconflicting option strings: %srcSsg|]\}}|�qSr*r*)rYr�rur*r*r+r\	s�z<_ActionsContainer._handle_conflict_error.<locals>.<listcomp>)rrnr$r)r%ru�conflicting_actionsr�Zconflict_stringr*r*r+�_handle_conflict_errors�
�z(_ActionsContainer._handle_conflict_errorcCs>|D]4\}}|j�|�|j�|d�|js|j�|�qdSr-)r�rXr=r�rVrY)r%rurar�r*r*r+�_handle_conflict_resolves
z*_ActionsContainer._handle_conflict_resolve)N)N)rr2r3rPr:rErGrHrwrRrTrNrYr\rJrKrLr;rUrbrcr�r*r*r�r+r2�s$5
	
3($
		r2cs6eZdZd�fdd�	Z�fdd�Z�fdd�Z�ZS)	rQNcs�|j}|d|j�|d|j�|d|j�tt|�j}|fd|i|��||_g|_|j	|_	|j
|_
|j|_|j|_|j
|_
|j|_dS)Nr8r7r6r5)rr8r7r6r�rQrPrZr�r9r<r=r@rBr?)r%rVrZr5rrFZ
super_initr�r*r+rPs�z_ArgumentGroup.__init__cs tt|��|�}|j�|�|Sr-)r�rQrNr�r r�r�r*r+rN5sz_ArgumentGroup._add_actioncs tt|��|�|j�|�dSr-)r�rQrYr�rXr�r�r*r+rY:sz_ArgumentGroup._remove_action)NN�rr2r3rPrNrYr�r*r*r�r+rQsrQcs.eZdZd�fdd�	Zdd�Zdd�Z�ZS)	rSFcs tt|��|�||_||_dSr-)r�rSrPr��
_container)r%rVr�r�r*r+rPAsz _MutuallyExclusiveGroup.__init__cCs2|jrtd�}t|��|j�|�}|j�|�|S)Nz-mutually exclusive arguments must be optional)r�r�r�rerNr�r )r%rurr*r*r+rNFsz#_MutuallyExclusiveGroup._add_actioncCs|j�|�|j�|�dSr-)rerYr�rXr�r*r*r+rYNsz&_MutuallyExclusiveGroup._remove_action)Frdr*r*r�r+rS?srScs&eZdZddddgeddddddf�fdd�	Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	d@dd�Z
dAdd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�ZdBd%d&�ZdCd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�ZdDd5d6�ZdEd7d8�ZdFd9d:�ZdGd<d=�Zd>d?�Z �Z!S)HrNr%r(Tc
	s"tt|�j}
|
|||	|
d�|dkr6tj�tjd�}||_||_	||_
||_||_||_
||_|j}|td��|_|td��|_d|_dd�}|�dd|�d|kr�dn|d}|j
r�|j|d	|d
ddttd�d
�|D]<}|�|�z
|j}Wntk
�rYq�X|j�|�q�dS)N)r5r7r6r8rzpositional argumentszoptional argumentscSs|Sr-r*)r+r*r*r+�identity�sz)ArgumentParser.__init__.<locals>.identityrr%�hr7rqzshow this help message and exit)rur�rq)r�rrP�_os�path�basenamer�argvrNrh�epilog�formatter_class�fromfile_prefix_chars�add_help�allow_abbrevrRr��_positionals�
_optionals�_subparsersr:rwrr\r@r�rF)r%rNrhr5rl�parentsrmr7rnr6r8rorpZ	superinitZ	add_grouprfZdefault_prefixrW�defaultsr�r*r+rPfsJ�
�

zArgumentParser.__init__cs"ddddddg}�fdd�|D�S)	NrNrhr5rmr8rocsg|]}|t�|�f�qSr*r�r�r1r*r+r\�sz.ArgumentParser._get_kwargs.<locals>.<listcomp>r*r�r*r1r+r"�s�zArgumentParser._get_kwargsc	Ks�|jdk	r|�td��|�dt|��d|ks8d|krht|�dd��}t|�dd��}|�||�|_n|j|_|�d�dkr�|�	�}|�
�}|j}|�|j
||d�|����|d<|�|d�}|fd	gi|��}|j�|�|S)
Nz(cannot have multiple subparser argumentsrrZr5ZsubcommandsrNr]r4r�)rsr(r�rrr�rRrqr�r�_get_positional_actionsr?rlrhr`r{rLrN)	r%rrZr5rVr�rjZ
parsers_classrur*r*r+�add_subparsers�s$
zArgumentParser.add_subparserscCs$|jr|j�|�n|j�|�|Sr-)r�rrrNrqr�r*r*r+rN�szArgumentParser._add_actioncCsdd�|jD�S)NcSsg|]}|jr|�qSr*�r��rYrur*r*r+r\�s�z8ArgumentParser._get_optional_actions.<locals>.<listcomp>�r<r1r*r*r+�_get_optional_actions�s�z$ArgumentParser._get_optional_actionscCsdd�|jD�S)NcSsg|]}|js|�qSr*rxryr*r*r+r\�s�z:ArgumentParser._get_positional_actions.<locals>.<listcomp>rzr1r*r*r+rv�s�z&ArgumentParser._get_positional_actionscCs4|�||�\}}|r0td�}|�|d�|��|S�Nzunrecognized arguments: %sr~)rr�r(r$�r%r[r�rkrr*r*r+�
parse_args�s
zArgumentParser.parse_argscCs|dkrtjdd�}nt|�}|dkr.t�}|jD]4}|jtk	r4t||j�s4|jtk	r4t	||j|j�q4|j
D] }t||�spt	|||j
|�qpz>|�||�\}}t|t�r�|�
t|t��t|t�||fWStk
�rt��d}|�t|��YnXdSrQ)rrkr4r
r<r�rr�r�r�r@�_parse_known_argsrr�r��delattrr�exc_infor(r�)r%r[r�rur��errr*r*r+r�s,







zArgumentParser.parse_known_argscs�	jdk	r�	����i��	jD]R}|j}t|j�D]<\}}��|g�}|�|d|��|�||dd��q2qi�g}t��}	t|	�D]^\}}
|
dkr�|�d�|	D]}
|�d�q�q��	�	|
�}|dkr�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|�
�
�k�r҈�
|�}��|�|�
|
�
��
�qd|�
�}���|d��g}�	jD]|}|�k�r|j�r(|�t|��nT|jdk	�rt|jt��rt�|j��r|jt�|j�k�rt�|j�	�||j���q|�r��	�td�d�
|���	jD]X}|j�r�|jD]}|�k�r��q��q�dd�|jD�}td�}�	�|d�
|���q���fS)NrR�--r%�A�Or]cs|��|���||�}||jk	rb��|���|g�D]*}|�kr6td�}t|�}t|||��q6|tk	rx|��||�dS)Nznot allowed with argument %s)r��_get_valuesr�r�r�r�rr)ruZargument_stringsr�Zargument_valuesZconflict_actionrZaction_name)�action_conflictsr��seen_actions�seen_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}|dd�p�d}
�j}||kr�||}|
}ntd�}t|||��nB|dkr�|d}
|g}|�|||f��q\ntd�}t|||��q|d}�|d�}|||�}||}
�||
�}|�|||f��q\q|D]\}}}�|||��q`|
S)NrRr�rzignored explicit argument %r)�_match_argumentr r7r=r�r)�start_index�option_tuplerur��explicit_argZmatch_argumentZ
action_tuples�	arg_countrO�charZnew_explicit_argZ
optionals_mapr�stopr[r�Zselected_patterns)r&�arg_strings_pattern�extras�option_string_indicesr%r�r*r+�consume_optionalUsL



z:ArgumentParser._parse_known_args.<locals>.consume_optionalcsn�j}�|d�}|�|�}t�|�D]*\}}�|||�}||7}�||�q&�t|�d��dd�<|Sr-)�_match_arguments_partial�ziprn)r�Z
match_partialZselected_patternZ
arg_countsrur�r[)r&r�r�r%r�r*r+�consume_positionals�s
z=ArgumentParser._parse_known_args.<locals>.consume_positionalsrr�csg|]}|�kr|�qSr*r*)rYr�)r�r*r+r\�s�z4ArgumentParser._parse_known_args.<locals>.<listcomp>z(the following arguments are required: %srcSsg|]}|jtk	rt|��qSr*)rqrr�ryr*r*r+r\�s
�z#one of the arguments %s is requiredr~)N)rn�_read_args_from_filesr?r�r�rr��iterr �_parse_optionalr$r�rvr@r?r<r�r�r�r�r�r�r�r�r��
_get_valuer(r�)r%r&r�r[r�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_actionsrur�r�rr*)r�r&r�r�r�r�r�r�r�r%r�r�r+rs�





J

�






�
���
�



�z ArgumentParser._parse_known_argsc
Cs�g}|D]�}|r|d|jkr*|�|�qzdt|dd���J}g}|����D]}|�|�D]}|�|�q\qN|�|�}|�|�W5QRXWqtk
r�t	�
�d}|�t|��YqXq|Sr�)
rnr r��readr��convert_arg_line_to_argsr�r�r*rr�r(r�)r%r&Znew_arg_stringsr�Z	args_file�arg_liner'r�r*r*r+r�s 
z$ArgumentParser._read_args_from_filescCs|gSr-r*)r%r�r*r*r+r�!sz'ArgumentParser.convert_arg_line_to_argscCsz|�|�}t�||�}|dkrldtd�ttd�ttd�i}|�|j�}|dkrbtdd|j�|j}t	||��t
|�d��S)Nzexpected one argumentzexpected at most one argumentzexpected at least one argumentzexpected %s argumentzexpected %s argumentsrR)�_get_nargs_patternrIrWr�r
rr�r�rrrnr�)r%rur��
nargs_patternrWZnargs_errorsrr*r*r+r�$s(
���
zArgumentParser._match_argumentcsrg}tt|�dd�D]X}|d|�}d��fdd�|D��}t�||�}|dk	r|�dd�|��D��qnq|S)Nrr�r]csg|]}��|��qSr*)r�ryr1r*r+r\@s�z;ArgumentParser._match_arguments_partial.<locals>.<listcomp>cSsg|]}t|��qSr*rm)rYr+r*r*r+r\Ds)r�rnr$rIrWr�rj)r%rir�r�r�Z
actions_slicer�rWr*r1r+r�:s�z'ArgumentParser._match_arguments_partialc
Cs|sdS|d|jkrdS||jkr8|j|}||dfSt|�dkrHdSd|kr~|�dd�\}}||jkr~|j|}|||fS|�|�}t|�dkr�d�dd�|D��}||d�}td�}|�||�nt|�dkr�|\}	|	S|j�	|�r�|j
s�dSd	|k�rdSd|dfS)
NrrR�=rcSsg|]\}}}|�qSr*r*)rYrur�r�r*r*r+r\is�z2ArgumentParser._parse_optional.<locals>.<listcomp>)r^Zmatchesz4ambiguous option: %(option)s could match %(matches)sr~)r7r=rn�split�_get_option_tuplesr$r�r(rArWrB)
r%r�rur�r�Z
option_tuplesZoptionsr[rr�r*r*r+r�Js>







�

zArgumentParser._parse_optionalc
Cs0g}|j}|d|kr�|d|kr�|jr~d|krB|�dd�\}}n|}d}|jD],}|�|�rP|j|}|||f}|�|�qPn�|d|k�r|d|k�r|}d}|dd�}|dd�}	|jD]T}||kr�|j|}|||	f}|�|�q�|�|�r�|j|}|||f}|�|�q�n|�td�|�|S)NrrRr�r7zunexpected option string: %s)r7rpr�r=�
startswithr r(r�)
r%r�r�rOZ
option_prefixr�rur�Zshort_option_prefixZshort_explicit_argr*r*r+r��s:









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-*r�r]r%)
r�r
rrrrrr$r�r`)r%rur�r�r*r*r+r��s(z!ArgumentParser._get_nargs_patterncCs4|�||�\}}|r0td�}|�|d�|��|Sr|)�parse_known_intermixed_argsr�r(r$r}r*r*r+�parse_intermixed_args�s
z$ArgumentParser.parse_intermixed_argsc	s�|���dd��D�}|r,td|dj���fdd�|jD�rHtd���zN|j}z�|jdkrp|��dd�|_�D] }|j|_t	|_|j|_t	|_qt|�
||�\}}�D]J}t||j�r�t
||j�gkr�ddlm}|d	|j|f�t||j�q�W5�D]}|j|_|j|_q�X|��}zJ|D]}|j|_d
|_�q$|jD]}	|	j|	_d
|	_�q@|�
||�\}}
W5|D]}|j|_�qn|jD]}	|	j|	_�q�XW5||_X||
fS)NcSsg|]}|jttfkr|�qSr*)r�rrryr*r*r+r\�s�z>ArgumentParser.parse_known_intermixed_args.<locals>.<listcomp>z3parse_intermixed_args: positional arg with nargs=%srcs&g|]}|jD]}|�kr|j�qqSr*)r�r�)rYr�ru�r�r*r+r\�s
�z;parse_intermixed_args: positional in mutuallyExclusiveGroup�)�warnzDo not expect %s in %sF)rvr�r�r?rhZ
save_nargsZsave_defaultr��format_usagerrr�r�r��warningsr�r�r{Z
save_requiredr�)r%r[r��aZ
save_usageruZremaining_argsr�r�r�r�r*r�r+r��s`
�
��


�
z*ArgumentParser.parse_known_intermixed_argscs��jttfkr2z|�d�Wntk
r0YnX|sz�jtkrz�jrN�j}n�j}t	|t
�rv���|�}���|��n|s��jt
kr��js��jdk	r��j}n|}���|�n�t|�dkr�jdtfkr�|\}���|�}���|�n��jtk�r��fdd�|D�}np�jtk�r@��fdd�|D�}���|d�n>�jtk�rRt}n,��fdd�|D�}|D]}���|��qj|S)Nr�rRcsg|]}���|��qSr*�r��rY�v�rur%r*r+r\Z	sz.ArgumentParser._get_values.<locals>.<listcomp>csg|]}���|��qSr*r�r�r�r*r+r\^	srcsg|]}���|��qSr*r�r�r�r*r+r\g	s)r�rrrXr�r
r�r�r�r�r�r��_check_valuerrnr)r%rur&r)r�r�r*r�r+r�6	sD
�
zArgumentParser._get_valuesc	Cs�|�d|j|j�}t|�s0td�}t|||��z||�}Wn�tk
r~t|jdt|j��}tt	�
�d�}t||��YnLttfk
r�t|jdt|j��}||d�}td�}t|||��YnX|S)NrrIrrR)rr)z!invalid %(type)s value: %(value)r)
rErrMr�rrr�r!r�rr�r�r�)r%rur�rPrr�r(r[r*r*r+r�n	s 
zArgumentParser._get_valuecCsF|jdk	rB||jkrB|d�tt|j��d�}td�}t|||��dS)Nr)r)r�z3invalid choice: %(value)r (choose from %(choices)s))r�r$�mapr!r�r)r%rur)r[rr*r*r+r��	s�zArgumentParser._check_valuecCs$|��}|�|j|j|j�|��Sr-)rrlrhr<r?r`)r%rVr*r*r+r��	s
�zArgumentParser.format_usagecCst|��}|�|j|j|j�|�|j�|jD]0}|�|j	�|�|j�|�
|j�|��q.|�|j
�|��Sr-)rrlrhr<r?rfr5r>rbrZrxr�rcrlr`)r%rVZaction_groupr*r*r+r`�	s�

zArgumentParser.format_helpcCs|j|jd�S)Nr})rmrNr1r*r*r+r�	szArgumentParser._get_formattercCs"|dkrtj}|�|��|�dSr-)rrrr��r%�filer*r*r+�print_usage�	szArgumentParser.print_usagecCs"|dkrtj}|�|��|�dSr-)rrrr`r�r*r*r+r�	szArgumentParser.print_helpcCs |r|dkrtj}|�|�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)N)rNr�r7z%(prog)s: error: %(message)s
)r�rr�rNrr�)r%r�r[r*r*r+r(�	s	zArgumentParser.error)NN)NN)NN)NN)N)N)N)rN)"rr2r3rrPr"rwrNr{rvr~rrr�r�r�r�r�r�r�r�r�r�r�r�r�r`rr�rrrr(r�r*r*r�r+rSsT�@

#w:-1

M8


	
)2�__version__�__all__�osrh�rerIZshutilr:�sysrrr�rrr
rrrrrr�rr6rrrrr	r��	Exceptionrrrr�r�r�r�r�r�r�r�rr	rrr
r2rQrSrr*r*r*r+�<module>As~�z
	[#&]7:"

?>