AlkantarClanX12

Your IP : 18.188.205.95


Current Path : /proc/self/root/usr/lib64/python3.6/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib64/python3.6/__pycache__/argparse.cpython-36.opt-2.pyc

3


 \a�@s,dZddddddddd	d
ddd
ddddgZddlZddlZddlZddlZ	ddl
ZddlZ
ddlmZmZdZdZdZdZdZdZdZGdd�de�Zdd�ZGd d�de�ZGd!d�de�ZGd"d�de�ZGd#d�de�ZGd$d	�d	e�Zd%d&�Z Gd'd�de!�Z"Gd(d�de!�Z#Gd)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�de�Z/Gd?d
�d
e�Z0Gd@dA�dAe�Z1GdBdC�dCe1�Z2GdDdE�dEe2�Z3GdFd�dee1�Z4dS)Gz1.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...Z_unrecognized_argsc@s$eZdZdd�Zdd�Zdd�ZdS)�_AttributeHoldercCs�t|�j}g}i}x|j�D]}|jt|��qWx8|j�D],\}}|j�r`|jd||f�q<|||<q<W|r�|jdt|��d|dj|�fS)Nz%s=%rz**%sz%s(%s)z, )�type�__name__�	_get_args�append�repr�_get_kwargs�isidentifier�join)�selfZ	type_name�arg_stringsZ	star_args�arg�name�value�r&� /usr/lib64/python3.6/argparse.py�__repr__vs
z_AttributeHolder.__repr__cCst|jj��S)N)�sorted�__dict__�items)r!r&r&r'r�sz_AttributeHolder._get_kwargscCsgS)Nr&)r!r&r&r'r�sz_AttributeHolder._get_argsN)r�
__module__�__qualname__r(rrr&r&r&r'rms	rcCs&t||d�dkrt|||�t||�S)N)�getattr�setattr)�	namespacer$r%r&r&r'�
_ensure_value�sr1c@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�|dkr@yttjd�}Wnttfk
r6d}YnX|d8}||_||_||_t|t	|d|d��|_||_
d|_d|_d|_
|j|d�|_|j|_tjdtj�|_tjd�|_dS)NZCOLUMNS�Pr2�rz\s+z\n\n\n+)�int�_os�environ�KeyError�
ValueError�_prog�_indent_increment�_max_help_position�min�max�_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�)rAr<rB)r!r&r&r'�_indent�szHelpFormatter._indentcCs"|j|j8_|jd8_dS)NrO)rAr<rB)r!r&r&r'�_dedent�szHelpFormatter._dedentc@seZdZddd�Zdd�ZdS)zHelpFormatter._SectionNcCs||_||_||_g|_dS)N)�	formatter�parent�headingr+)r!rRrSrTr&r&r'rN�szHelpFormatter._Section.__init__cCs�|jdk	r|jj�|jj}|dd�|jD��}|jdk	rD|jj�|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:
�
)	rSrRrP�_join_partsr+rQrTrrA)r!r Z	item_helpZcurrent_indentrTr&r&r'�format_help�s



z"HelpFormatter._Section.format_help)N)rr,r-rNr\r&r&r&r'rD�s
rDcCs|jjj||f�dS)N)rFr+r)r!rVrWr&r&r'�	_add_item�szHelpFormatter._add_itemcCs0|j�|j||j|�}|j|jg�||_dS)N)rPrDrFr]r\)r!rTZsectionr&r&r'�
start_section�szHelpFormatter.start_sectioncCs|jj|_|j�dS)N)rFrSrQ)r!r&r&r'�end_section�s
zHelpFormatter.end_sectioncCs$|tk	r |dk	r |j|j|g�dS)N)rr]�_format_text)r!�textr&r&r'�add_text�szHelpFormatter.add_textcCs&|tk	r"||||f}|j|j|�dS)N)rr]�
_format_usage)r!�usage�actions�groups�prefixrWr&r&r'�	add_usage�szHelpFormatter.add_usagecCsz|jtk	rv|j}||�g}x |j|�D]}|j||��q&Wtdd�|D��}||j}t|j|�|_|j|j	|g�dS)NcSsg|]}t|��qSr&)�len)rU�sr&r&r'rX
sz.HelpFormatter.add_argument.<locals>.<listcomp>)
�helpr�_format_action_invocation�_iter_indented_subactionsrr?rArCr]�_format_action)r!�actionZget_invocationZinvocations�	subactionZinvocation_lengthZ
action_lengthr&r&r'�add_arguments


zHelpFormatter.add_argumentcCsx|D]}|j|�qWdS)N)rq)r!reror&r&r'�
add_argumentss
zHelpFormatter.add_argumentscCs.|jj�}|r*|jjd|�}|jd�d}|S)Nz

rZ)rEr\rK�sub�strip)r!rkr&r&r'r\s

zHelpFormatter.format_helpcCsdjdd�|D��S)NrYcSsg|]}|r|tk	r|�qSr&)r)rU�partr&r&r'rX!sz-HelpFormatter._join_parts.<locals>.<listcomp>)r )r!Zpart_stringsr&r&r'r[ s
zHelpFormatter._join_partscs|dkrtd�}|dk	r,|t|jd�}�n�|dkrN|rNdt|jd�}�n�|dk�rdt|jd�}g}g}x(|D] }|jr�|j|�qv|j|�qvW|j}	|	|||�}
djdd�||
gD��}|j|j�t	|�t	|��k�rd}|	||�}|	||�}
t
j||�}t
j||
�}d�fdd	�	}t	|�t	|�d
�k�r�dt	|�t	|�d}|�r�||g|||�}|j|||��n |�r�||g|||�}n|g}nZdt	|�}||}|||�}t	|�dk�r�g}|j|||��|j|||��|g|}dj|�}d
||fS)Nzusage: )rLz%(prog)s� cSsg|]}|r|�qSr&r&)rUrjr&r&r'rXAsz/HelpFormatter._format_usage.<locals>.<listcomp>z%\(.*?\)+(?=\s|$)|\[.*?\]+(?=\s|$)|\S+cs�g}g}|dk	rt|�d}nt|�d}xb|D]Z}|dt|��krp|rp|j|dj|��g}t|�d}|j|�|t|�d7}q0W|r�|j|dj|��|dk	r�|dt|�d�|d<|S)NrOrvr)rirr )�parts�indentrg�lines�lineZline_lenru)�
text_widthr&r'�	get_linesUs"

z.HelpFormatter._format_usage.<locals>.get_linesg�?rOrZz%s%s

)N)
�_�dictr;�option_stringsr�_format_actions_usager r@rArirG�findall�extend)r!rdrerfrgrLZ	optionals�positionalsro�formatZaction_usageZpart_regexpZ	opt_usageZ	pos_usageZ	opt_partsZ	pos_partsr|rxryrwr&)r{r'rc%sV






zHelpFormatter._format_usagec
Cs�t�}i}x�|D]�}y|j|jd�}Wntk
r>wYqX|t|j�}|||�|jkrx|jD]}|j|�qhW|js�||kr�||d7<nd||<d||<n*||kr�||d7<nd||<d||<xt|d|�D]}	d	||	<q�WqWg}
�x2t|�D�]$\}	}|j	t
k�rj|
jd�|j|	�d	k�rF|j
|	�n"|j|	d�d	k�r.|j
|	d�n�|j�s�|j|�}|j||�}||k�r�|ddk�r�|ddk�r�|dd�}|
j|�nh|jd}
|jdk�r�d
|
}n"|j|�}|j||�}d|
|f}|j�r$||k�r$d|}|
j|��q
Wx(t|d
d�D]}	||	g|
|	|	�<�qBWdjdd�|
D��}d}d}tjd|d|�}tjd|d|�}tjd||fd|�}tjdd|�}|j�}|S)Nrz [�[�]z (�(�)rO�|z%sz%s %sz[%s]T)�reverservcSsg|]}|dk	r|�qS)Nr&)rU�itemr&r&r'rX�sz7HelpFormatter._format_actions_usage.<locals>.<listcomp>z[\[(]z[\])]z(%s) z\1z (%s)z%s *%srYz\(([^|]*)\)���r�)�set�index�_group_actionsr:ri�add�required�range�	enumeraterkrr�get�popr�#_get_default_metavar_for_positional�_format_args�nargs�!_get_default_metavar_for_optionalr)r rGrsrt)r!rerf�
group_actionsZinserts�group�start�endro�irw�defaultru�
option_string�args_stringra�open�closer&r&r'r��sr







z#HelpFormatter._format_actions_usagecCsFd|kr|t|jd�}t|j|jd�}d|j}|j|||�dS)Nz%(prog))rL�rvz

)r~r;r?r@rA�
_fill_text)r!rar{rxr&r&r'r`�s

zHelpFormatter._format_textc
CsBt|jd|j�}t|j|d�}||jd}|j|�}|jsV|jd|f}d|}n@t|�|kr~|jd||f}d|}d}n|jd|f}d|}|}|g}|jr�|j	|�}	|j
|	|�}
|jd|d|
df�x@|
dd�D]}|jd|d|f�q�Wn|jd��s|jd�x$|j
|�D]}|j|j|���qW|j|�S)	Nr2r�rYz%*s%s
z	%*s%-*s  rrOrZ)r>rCr=r?r@rArlrkri�_expand_help�_split_linesr�endswithrmrnr[)
r!roZ
help_positionZ
help_widthZaction_widthZ
action_header�tupZindent_firstrwZ	help_textZ
help_linesrzrpr&r&r'rn�s6




zHelpFormatter._format_actioncCs�|js&|j|�}|j||�d�\}|Sg}|jdkrB|j|j�n8|j|�}|j||�}x |jD]}|jd||f�q`Wdj|�SdS)NrOrz%s %sz, )	rr��_metavar_formatterr�r�r�r�rr )r!ror��metavarrwr�r�r&r&r'rls


z'HelpFormatter._format_action_invocationcsP|jdk	r|j�n.|jdk	r<dd�|jD�}ddj|��n|��fdd�}|S)NcSsg|]}t|��qSr&)�str)rUZchoicer&r&r'rX8sz4HelpFormatter._metavar_formatter.<locals>.<listcomp>z{%s}�,cst�t�r�S�f|SdS)N)�
isinstance�tuple)Z
tuple_size)�resultr&r'r�=s
z0HelpFormatter._metavar_formatter.<locals>.format)r��choicesr )r!ro�default_metavarZchoice_strsr�r&)r�r'r�4s

z HelpFormatter._metavar_formattercCs�|j||�}|jdkr$d|d�}n�|jtkr<d|d�}n�|jtkrTd|d�}nh|jtkrld|d�}nP|jtkr|d}n@|jtkr�d|d�}n(d	d
�t|j�D�}dj|�||j�}|S)Nz%srOz[%s]z
[%s [%s ...]]r2z%s [%s ...]z...z%s ...cSsg|]}d�qS)z%sr&)rUr}r&r&r'rXSsz.HelpFormatter._format_args.<locals>.<listcomp>rv)	r�r�r
rrrrr�r )r!ror�Zget_metavarr�Zformatsr&r&r'r�Ds 





zHelpFormatter._format_argscCs�tt|�|jd�}x"t|�D]}||tkr||=qWx,t|�D] }t||d�r@||j||<q@W|jd�dk	r�djdd�|dD��}||d<|j	|�|S)N)rLrr�z, cSsg|]}t|��qSr&)r�)rU�cr&r&r'rX`sz.HelpFormatter._expand_help.<locals>.<listcomp>)
r~�varsr;�listr�hasattrrr�r �_get_help_string)r!roZparamsr$Zchoices_strr&r&r'r�Ws
zHelpFormatter._expand_helpccs@y
|j}Wntk
rYnX|j�|�EdH|j�dS)N)�_get_subactions�AttributeErrorrPrQ)r!roZget_subactionsr&r&r'rmds
z'HelpFormatter._iter_indented_subactionscCs|jjd|�j�}tj||�S)Nrv)rJrsrt�	_textwrapZwrap)r!rarMr&r&r'r�nszHelpFormatter._split_linescCs$|jjd|�j�}tj||||d�S)Nrv)Zinitial_indentZsubsequent_indent)rJrsrtr�Zfill)r!rarMrxr&r&r'r�rs
zHelpFormatter._fill_textcCs|jS)N)rk)r!ror&r&r'r�wszHelpFormatter._get_help_stringcCs
|jj�S)N)�dest�upper)r!ror&r&r'r�zsz/HelpFormatter._get_default_metavar_for_optionalcCs|jS)N)r�)r!ror&r&r'r�}sz1HelpFormatter._get_default_metavar_for_positional)r2r3N)N)rr,r-rNrPrQ�objectrDr]r^r_rbrhrqrrr\r[rcr�r`rnrlr�r�r�rmr�r�r�r�r�r&r&r&r'r�s:	

`a/

c@seZdZdd�ZdS)rcs dj�fdd�|jdd�D��S)NrYc3s|]}�|VqdS)Nr&)rUrz)rxr&r'�	<genexpr>�sz9RawDescriptionHelpFormatter._fill_text.<locals>.<genexpr>T)�keepends)r �
splitlines)r!rarMrxr&)rxr'r��sz&RawDescriptionHelpFormatter._fill_textN)rr,r-r�r&r&r&r'r�sc@seZdZdd�ZdS)rcCs|j�S)N)r�)r!rarMr&r&r'r��sz!RawTextHelpFormatter._split_linesN)rr,r-r�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))rkr�rr
rrr�)r!rorkZdefaulting_nargsr&r&r'r��s

z.ArgumentDefaultsHelpFormatter._get_help_stringN)rr,r-r�r&r&r&r'r�sc@seZdZdd�Zdd�ZdS)r	cCs|jjS)N)rr)r!ror&r&r'r��sz:MetavarTypeHelpFormatter._get_default_metavar_for_optionalcCs|jjS)N)rr)r!ror&r&r'r��sz<MetavarTypeHelpFormatter._get_default_metavar_for_positionalN)rr,r-r�r�r&r&r&r'r	�scCsN|dkrdS|jrdj|j�S|jdtfkr2|jS|jdtfkrF|jSdSdS)N�/)rr r�rr�)�argumentr&r&r'�_get_action_name�sr�c@seZdZdd�Zdd�ZdS)rcCst|�|_||_dS)N)r��
argument_name�message)r!r�r�r&r&r'rN�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)rr,r-rNr�r&r&r&r'r�sc@seZdZdS)rN)rr,r-r&r&r&r'r�sc@s(eZdZd	dd�Zdd�Zd
dd�ZdS)rNFcCs@||_||_||_||_||_||_||_||_|	|_|
|_	dS)N)
rr�r��constr�rr�r�rkr�)r!rr�r�r�r�rr�r�rkr�r&r&r'rNszAction.__init__c	s(ddddddddd	g	}�fd
d�|D�S)Nrr�r�r�r�rr�rkr�csg|]}|t�|�f�qSr&)r.)rUr$)r!r&r'rX;sz&Action._get_kwargs.<locals>.<listcomp>r&)r!�namesr&)r!r'r/szAction._get_kwargscCsttd���dS)Nz.__call__() not defined)�NotImplementedErrorr})r!�parserr0�valuesr�r&r&r'�__call__=szAction.__call__)NNNNNFNN)N)rr,r-rNrr�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 appropriatez nargs must be %r to supply const)
rr�r�r�r�rr�r�rkr�)r:r
�superr�rN)r!rr�r�r�r�rr�r�rkr�)�	__class__r&r'rNCs
z_StoreAction.__init__cCst||j|�dS)N)r/r�)r!r�r0r�r�r&r&r'r�`sz_StoreAction.__call__)NNNNNFNN)N)rr,r-rNr��
__classcell__r&r&)r�r'r�Asr�cs(eZdZd�fdd�	Zddd�Z�ZS)	�_StoreConstActionNFc	s"tt|�j||d||||d�dS)Nr)rr�r�r�r�r�rk)r�r�rN)r!rr�r�r�r�rkr�)r�r&r'rNfs
z_StoreConstAction.__init__cCst||j|j�dS)N)r/r�r�)r!r�r0r�r�r&r&r'r�wsz_StoreConstAction.__call__)NFNN)N)rr,r-rNr�r�r&r&)r�r'r�ds

r�cseZdZd�fdd�	Z�ZS)�_StoreTrueActionFNcs tt|�j||d|||d�dS)NT)rr�r�r�r�rk)r�r�rN)r!rr�r�r�rk)r�r&r'rN}s
z_StoreTrueAction.__init__)FFN)rr,r-rNr�r&r&)r�r'r�{sr�cseZdZd�fdd�	Z�ZS)�_StoreFalseActionTFNcs tt|�j||d|||d�dS)NF)rr�r�r�r�rk)r�r�rN)r!rr�r�r�rk)r�r&r'rN�s
z_StoreFalseAction.__init__)TFN)rr,r-rNr�r&r&)r�r'r��sr�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 appropriatez nargs must be %r to supply const)
rr�r�r�r�rr�r�rkr�)r:r
r�r�rN)r!rr�r�r�r�rr�r�rkr�)r�r&r'rN�s
z_AppendAction.__init__cCs0tjt||jg��}|j|�t||j|�dS)N)�_copy�copyr1r�rr/)r!r�r0r�r�r+r&r&r'r��s
z_AppendAction.__call__)NNNNNFNN)N)rr,r-rNr�r�r&r&)r�r'r��sr�cs(eZdZd�fdd�	Zddd�Z�ZS)	�_AppendConstActionNFc
s$tt|�j||d|||||d�dS)Nr)rr�r�r�r�r�rkr�)r�r�rN)r!rr�r�r�r�rkr�)r�r&r'rN�s
z_AppendConstAction.__init__cCs2tjt||jg��}|j|j�t||j|�dS)N)r�r�r1r�rr�r/)r!r�r0r�r�r+r&r&r'r��sz_AppendConstAction.__call__)NFNN)N)rr,r-rNr�r�r&r&)r�r'r��s
r�cs(eZdZd�fdd�	Zddd�Z�ZS)	�_CountActionNFcs tt|�j||d|||d�dS)Nr)rr�r�r�r�rk)r�r�rN)r!rr�r�r�rk)r�r&r'rN�s
z_CountAction.__init__cCs$t||jd�d}t||j|�dS)NrrO)r1r�r/)r!r�r0r�r�Z	new_countr&r&r'r��sz_CountAction.__call__)NFN)N)rr,r-rNr�r�r&r&)r�r'r��s	r�cs.eZdZeedf�fdd�	Zddd�Z�ZS)�_HelpActionNcstt|�j|||d|d�dS)Nr)rr�r�r�rk)r�r�rN)r!rr�r�rk)r�r&r'rN�s
z_HelpAction.__init__cCs|j�|j�dS)N)�
print_help�exit)r!r�r0r�r�r&r&r'r��sz_HelpAction.__call__)N)rr,r-rrNr�r�r&r&)r�r'r��sr�cs0eZdZdeedf�fdd�	Zddd�Z�ZS)�_VersionActionNz&show program's version number and exitcs$tt|�j|||d|d�||_dS)Nr)rr�r�r�rk)r�r�rN�version)r!rr�r�r�rk)r�r&r'rNs
z_VersionAction.__init__cCsD|j}|dkr|j}|j�}|j|�|j|j�tj�|j�dS)N)r��_get_formatterrb�_print_messager\�_sys�stdoutr�)r!r�r0r�r�r�rRr&r&r'r�s
z_VersionAction.__call__)N)rr,r-rrNr�r�r&r&)r�r'r�s
	r�csNeZdZGdd�de�Zeddf�fdd�	Zdd�Zdd	�Zdd
d�Z	�Z
S)
�_SubParsersActioncseZdZ�fdd�Z�ZS)z&_SubParsersAction._ChoicesPseudoActioncs@|}}|r|ddj|�7}ttj|�}|jg|||d�dS)Nz (%s)z, )rr�rkr�)r r�r��_ChoicesPseudoActionrN)r!r$�aliasesrkr�r�Zsup)r�r&r'rN"s
z/_SubParsersAction._ChoicesPseudoAction.__init__)rr,r-rNr�r&r&)r�r'r� sr�Ncs>||_||_tj�|_g|_tt|�j||t	|j||d�dS)N)rr�r�r�rkr�)
�_prog_prefix�
_parser_class�_collections�OrderedDict�_name_parser_map�_choices_actionsr�r�rNr)r!rrL�parser_classr�rkr�)r�r&r'rN*s

z_SubParsersAction.__init__cKs�|jd�dkr d|j|f|d<|jdf�}d|krX|jd�}|j|||�}|jj|�|jf|�}||j|<x|D]}||j|<qtW|S)NrLz%s %sr�rk)r�r�r�r�r�rr�r�)r!r$�kwargsr�rkZ
choice_actionr��aliasr&r&r'�
add_parser?s


z_SubParsersAction.add_parsercCs|jS)N)r�)r!r&r&r'r�Vsz!_SubParsersAction._get_subactionsc
Cs�|d}|dd�}|jtk	r,t||j|�y|j|}Wn<tk
rv|dj|j�d�}td�|}t||��YnX|j|d�\}	}x$t	|	�j
�D]\}
}t||
|�q�W|r�t	|�jtg�t
|t�j|�dS)NrrOz, )�parser_namer�z5unknown parser %(parser_name)r (choices: %(choices)s))r�rr/r�r9r r}r�parse_known_argsr�r+�
setdefault�_UNRECOGNIZED_ARGS_ATTRr.r�)r!r�r0r�r�r�r"rW�msgZsubnamespace�keyr%r&r&r'r�Ys"
	z_SubParsersAction.__call__)N)rr,r-rr�rrNr�r�r�r�r&r&)r�r'r�sr�c@s&eZdZddd�Zdd�Zdd	�ZdS)r�rrONcCs||_||_||_||_dS)N)�_mode�_bufsize�	_encoding�_errors)r!�mode�bufsize�encoding�errorsr&r&r'rN�szFileType.__init__cCs�|dkr>d|jkrtjSd|jkr(tjStd�|j}t|��yt||j|j|j|j	�St
k
r�}ztd�}t|||f��WYdd}~XnXdS)N�-r��wzargument "-" with mode %rzcan't open '%s': %s)r�r��stdinr�r}r:r�r�r�r��OSErrorr)r!�stringr��er�r&r&r'r��s

zFileType.__call__cCsT|j|jf}d|jfd|jfg}djdd�|D�dd�|D��}dt|�j|fS)Nr�r�z, cSsg|]}|dkrt|��qS)rOr�)r)rUr#r&r&r'rX�sz%FileType.__repr__.<locals>.<listcomp>cSs$g|]\}}|dk	rd||f�qS)Nz%s=%rr&)rU�kwr#r&r&r'rX�sz%s(%s))r�r�r�r�r rr)r!rWr�Zargs_strr&r&r'r(�s
zFileType.__repr__r�)r�r�NN)rr,r-rNr�r(r&r&r&r'r~s
c@s$eZdZdd�Zdd�Zdd�ZdS)r
cKs"x|D]}t||||�qWdS)N)r/)r!r�r$r&r&r'rN�s
zNamespace.__init__cCst|t�stSt|�t|�kS)N)r�r
�NotImplementedr�)r!�otherr&r&r'�__eq__�s
zNamespace.__eq__cCs
||jkS)N)r*)r!r�r&r&r'�__contains__�szNamespace.__contains__N)rr,r-rNrrr&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|�j�||_||_||_||_i|_|jddt	�|jddt	�|jddt
�|jddt�|jddt�|jddt
�|jddt�|jddt�|jdd	t�|jdd
t�|jddt�|j�g|_i|_g|_g|_i|_tjd�|_g|_dS)
NroZstoreZstore_const�
store_trueZstore_falserZappend_const�countrkr��parsersz^-\d+$|^-\d*\.\d+$)r�r	rN�description�argument_default�prefix_chars�conflict_handler�_registries�registerr�r�r�r�r�r�r�r�r�r��_get_handler�_actions�_option_string_actions�_action_groups�_mutually_exclusive_groups�	_defaultsrGrH�_negative_number_matcher�_has_negative_number_optionals)r!r
rrr)r�r&r'rN�s2z_ActionsContainer.__init__cCs|jj|i�}|||<dS)N)rr�)r!�
registry_namer%r��registryr&r&r'r�sz_ActionsContainer.registerNcCs|j|j||�S)N)rr�)r!rr%r�r&r&r'�
_registry_getsz_ActionsContainer._registry_getcKs6|jj|�x$|jD]}|j|kr||j|_qWdS)N)r�updaterr�r�)r!r�ror&r&r'�set_defaultss
z_ActionsContainer.set_defaultscCs8x(|jD]}|j|kr|jdk	r|jSqW|jj|d�S)N)rr�r�rr�)r!r�ror&r&r'�get_defaults
z_ActionsContainer.get_defaultcOs0|j}|s(t|�dkrJ|dd|krJ|r<d|kr<td��|j||�}n|j||�}d|kr�|d}||jkr�|j||d<n|jdk	r�|j|d<|j|�}t|�s�td|f��|f|�}|j	d|j
|j
�}t|�s�td|f��t|d	��r&y|j�j
|d�Wntk
�r$td
��YnX|j|�S)NrOrr�z+dest supplied twice for positional argumentr�zunknown action "%s"rz%r is not callabler�z,length of metavar tuple does not match nargs)rrir:�_get_positional_kwargs�_get_optional_kwargsrr�_pop_action_class�callablerrr�r�r��	TypeError�_add_action)r!rWr��charsr�Zaction_classro�	type_funcr&r&r'rqs2	"




z_ActionsContainer.add_argumentcOs t|f|�|�}|jj|�|S)N)�_ArgumentGrouprr)r!rWr�r�r&r&r'�add_argument_groupJsz$_ActionsContainer.add_argument_groupcKst|f|�}|jj|�|S)N)�_MutuallyExclusiveGrouprr)r!r�r�r&r&r'�add_mutually_exclusive_groupOsz._ActionsContainer.add_mutually_exclusive_groupcCsh|j|�|jj|�||_x|jD]}||j|<q$Wx,|jD]"}|jj|�r>|js>|jjd�q>W|S)NT)	�_check_conflictrr�	containerrrr�matchr)r!ror�r&r&r'r&Ts
z_ActionsContainer._add_actioncCs|jj|�dS)N)r�remove)r!ror&r&r'�_remove_actionisz _ActionsContainer._remove_actioncCs�i}x8|jD].}|j|kr0td�}t||j��|||j<qWi}xR|jD]H}|j|krt|j|j|j|jd�||j<x|jD]}||j||<q|WqJWx4|jD]*}|j	|j
d�}x|jD]}|||<q�Wq�Wx |jD]}|j||�j
|�q�WdS)Nz.cannot merge actions - two groups are named %r)�titler
r)r�)rr2r}r:r*r
rr�rr,r�rr�r&)r!r.Ztitle_group_mapr�r�Z	group_mapro�mutex_groupr&r&r'�_add_container_actionsls,


z(_ActionsContainer._add_container_actionscKs^d|krtd�}t|��|jd�ttgkr2d|d<|jd�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�r�r�r&r&r'r!�sz(_ActionsContainer._get_positional_kwargsc	Os�g}g}xv|D]n}|d|jkr@||jd�}td�}t||��|j|�|d|jkrt|�dkr|d|jkr|j|�qW|jdd�}|dkr�|r�|d}n|d}|j|j�}|s�td�}t||��|jdd�}t|||d	�S)
Nr)�optionrzNinvalid option string %(option)r: must start with a character %(prefix_chars)rrOr�z%dest= is required for options like %rr�r})r�r)	rr}r:rrir��lstrip�replacer~)	r!rWr�rZlong_option_stringsr�r�r�Zdest_option_stringr&r&r'r"�s0



z&_ActionsContainer._get_optional_kwargscCs|jd|�}|jd||�S)Nro)r�r)r!r�r�ror&r&r'r#�sz#_ActionsContainer._pop_action_classcCsDd|j}y
t||�Stk
r>td�}t||j��YnXdS)Nz_handle_conflict_%sz%invalid conflict_resolution value: %r)rr.r�r}r:)r!Zhandler_func_namer�r&r&r'r�s

z_ActionsContainer._get_handlercCsPg}x0|jD]&}||jkr|j|}|j||f�qW|rL|j�}|||�dS)N)rrrr)r!roZconfl_optionalsr�Zconfl_optionalrr&r&r'r-�s

z!_ActionsContainer._check_conflictcCs6tddt|��}djdd�|D��}t|||��dS)Nzconflicting option string: %szconflicting option strings: %sz, cSsg|]\}}|�qSr&r&)rUr�ror&r&r'rX�sz<_ActionsContainer._handle_conflict_error.<locals>.<listcomp>)rrir r)r!ro�conflicting_actionsr�Zconflict_stringr&r&r'�_handle_conflict_error�s


z(_ActionsContainer._handle_conflict_errorcCsBx<|D]4\}}|jj|�|jj|d�|js|jj|�qWdS)N)rr0rr�r.r1)r!ror8r�r&r&r'�_handle_conflict_resolve�s
z*_ActionsContainer._handle_conflict_resolve)N)N)rr,r-rNrrrr rqr*r,r&r1r4r!r"r#rr-r9r:r�r&r&)r�r'r	�s$4
	
/($
		r	cs6eZdZd�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)Nrrrr
)r�rrrr�r)rNr2r�rrrrrr)r!r.r2r
r�rZ
super_init)r�r&r'rN�sz_ArgumentGroup.__init__cs tt|�j|�}|jj|�|S)N)r�r)r&r�r)r!ro)r�r&r'r&sz_ArgumentGroup._add_actioncs tt|�j|�|jj|�dS)N)r�r)r1r�r0)r!ro)r�r&r'r1sz_ArgumentGroup._remove_action)NN)rr,r-rNr&r1r�r&r&)r�r'r)�sr)cs.eZdZd�fdd�	Zdd�Zdd�Z�ZS)	r+Fcs tt|�j|�||_||_dS)N)r�r+rNr��
_container)r!r.r�)r�r&r'rNsz _MutuallyExclusiveGroup.__init__cCs2|jrtd�}t|��|jj|�}|jj|�|S)Nz-mutually exclusive arguments must be optional)r�r}r:r;r&r�r)r!ror�r&r&r'r&$sz#_MutuallyExclusiveGroup._add_actioncCs|jj|�|jj|�dS)N)r;r1r�r0)r!ror&r&r'r1,sz&_MutuallyExclusiveGroup._remove_action)F)rr,r-rNr&r1r�r&r&)r�r'r+sr+cseZdZddddgeddddddf�fdd�	Zdd�Zd	d
�Zdd�Zd
d�Zdd�Z	d<dd�Z
d=dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd>d1d2�Zd?d3d4�Zd@d5d6�ZdAd8d9�Zd:d;�Z�ZS)BrNr��errorTc
s&tt|�j}
|
|||	|
d�|dkr6tjjtjd�}||_||_	||_
||_||_||_
||_|j}|td��|_|td��|_d|_dd�}|jdd|�d|kr�dn|d}|j
r�|j|d	|d
ddttd�d
�xD|D]<}|j|�y
|j}Wntk
�rYq�X|jj|�q�WdS)N)r
rrrrzpositional argumentszoptional argumentscSs|S)Nr&)rr&r&r'�identityjsz)ArgumentParser.__init__.<locals>.identityrr��hr2rkzshow this help message and exit)ror�rk)r�rrNr7�path�basenamer��argvrLrd�epilog�formatter_class�fromfile_prefix_chars�add_help�allow_abbrevr*r}�_positionals�
_optionals�_subparsersrrqrr4rr�r)r!rLrdr
rB�parentsrCrrDrrrErFZ	superinitZ	add_groupr=Zdefault_prefixrSZdefaults)r�r&r'rNDsB


zArgumentParser.__init__cs"ddddddg}�fdd�|D�S)	NrLrdr
rCrrEcsg|]}|t�|�f�qSr&)r.)rUr$)r!r&r'rX�sz.ArgumentParser._get_kwargs.<locals>.<listcomp>r&)r!r�r&)r!r'r�szArgumentParser._get_kwargsc	Ks�|jdk	r|jtd��|jdt|��d|ks8d|krht|jdd��}t|jdd��}|j||�|_n|j|_|jd�dkr�|j	�}|j
�}|j}|j|j
||d�|j�j�|d<|j|d�}|fd	gi|��}|jj|�|S)
Nz(cannot have multiple subparser argumentsr�r2r
ZsubcommandsrLrYrr)rIr<r}r�rr�r*rGr�r��_get_positional_actionsrrhrdr\rtr#r&)	r!r�r2r
rRr�rfZ
parsers_classror&r&r'�add_subparsers�s$
zArgumentParser.add_subparserscCs$|jr|jj|�n|jj|�|S)N)rrHr&rG)r!ror&r&r'r&�szArgumentParser._add_actioncCsdd�|jD�S)NcSsg|]}|jr|�qSr&)r)rUror&r&r'rX�sz8ArgumentParser._get_optional_actions.<locals>.<listcomp>)r)r!r&r&r'�_get_optional_actions�sz$ArgumentParser._get_optional_actionscCsdd�|jD�S)NcSsg|]}|js|�qSr&)r)rUror&r&r'rX�sz:ArgumentParser._get_positional_actions.<locals>.<listcomp>)r)r!r&r&r'rK�sz&ArgumentParser._get_positional_actionscCs4|j||�\}}|r0td�}|j|dj|��|S)Nzunrecognized arguments: %srv)r�r}r<r )r!rWr0rAr�r&r&r'�
parse_args�s
zArgumentParser.parse_argscCs|dkrtjdd�}nt|�}|dkr.t�}x>|jD]4}|jtk	r6t||j�s6|jtk	r6t	||j|j�q6Wx*|j
D] }t||�svt	|||j
|�qvWy<|j||�\}}t|t�r�|j
t|t��t|t�||fStk
�rtj�d}|jt|��YnXdS)NrO)r�rAr�r
rr�rr�r�r/r�_parse_known_argsr�r�r.�delattrr�exc_infor<r�)r!rWr0ror��errr&r&r'r��s,




zArgumentParser.parse_known_argscs"�	jdk	r�	j���i�x`�	jD]V}|j}xJt|j�D]<\}}�j|g�}|j|d|��|j||dd��q6Wq Wi�g}t��}	xnt|	�D]b\}}
|
dkr�|jd�xF|	D]}
|jd�q�Wq��	j	|
�}|dkr�d}n|�|<d}|j|�q�Wdj
|��t��t��d�����	fdd�	������	�fd	d
�}
�	j������	�fdd�}g�d
�
��rpt
��}nd}x|�
|k�r�t�
fdd��D��}�
|k�r�|�
�}|�
k�r�|�
�qvn|�
�
�k�r��
|�}�j|�|�
|
�
��
�qvW|�
�}�j�|d��g}x��	jD]|}|�k�r|j�r>|jt|��nT|jdk	�rt|jt��rt�|j��r|jt�|j�k�rt�|j�	j||j���qW|�r��	jtd�dj
|��xb�	jD]X}|j�r�xH|jD]}|�k�r�P�q�Wdd�|jD�}td�}�	j|dj
|���q�W��fS)NrOz--r��A�OrYcs��j|��j||�}||jk	rf�j|�x:�j|g�D]*}|�kr8td�}t|�}t|||��q8W|tk	r||��||�dS)Nznot allowed with argument %s)r��_get_valuesr�r�r}r�rr)roZargument_stringsr�Zargument_valuesZconflict_actionr�Zaction_name)�action_conflictsr0�seen_actions�seen_non_default_actionsr!r&r'�take_actions


z5ArgumentParser._parse_known_args.<locals>.take_actioncs��|}|\}}}�j}g}�x>|dkr>�j�|�|dS|dk	�r||d�}�j}|dkr�|d|kr�|j|g|f�|d}	|	|d}|dd�p�d}
�j}||kr�||}|
}ntd�}t|||��n@|dkr�|d}
|g}|j|||f�Pntd�}t|||��q |d}�|d�}|||�}||}
�||
�}|j|||f�Pq Wx |D]\}}}�|||��qdW|
S)NrOrSrzignored explicit argument %r)�_match_argumentrrrr}r)�start_index�option_tupleror��explicit_argZmatch_argumentZ
action_tuples�	arg_countr'�charZnew_explicit_argZ
optionals_mapr��stoprWr�Zselected_patterns)r"�arg_strings_pattern�extras�option_string_indicesr!rYr&r'�consume_optional3sN



z:ArgumentParser._parse_known_args.<locals>.consume_optionalcsr�j}�|d�}|�|�}x8t�|�D]*\}}�|||�}||7}�||�q(W�t|�d��dd�<|S)N)�_match_arguments_partial�zipri)r[Z
match_partialZselected_patternZ
arg_countsror^rW)r"rar�r!rYr&r'�consume_positionals�s
z=ArgumentParser._parse_known_args.<locals>.consume_positionalsrcsg|]}|�kr|�qSr&r&)rUr�)r[r&r'rX�sz4ArgumentParser._parse_known_args.<locals>.<listcomp>z(the following arguments are required: %sz, cSsg|]}|jtk	rt|��qSr&)rkrr�)rUror&r&r'rX�sz#one of the arguments %s is requiredrv)Nr�)rD�_read_args_from_filesrr�r�r�r��iterr�_parse_optionalr r�rKr?r>rr�r�r�r�r�r�r�r.r/�
_get_valuer<r})r!r"r0r3r�r�Zmutex_actionZ	conflictsZarg_string_pattern_partsZarg_strings_iter�
arg_stringr\�patternrdrgZmax_option_string_indexZnext_option_string_indexZpositionals_end_indexZstringsZ
stop_indexZrequired_actionsror�r�r�r&)rVr"rarbr0rcr�rWrXr!r[rYr'rO�s�





J










z ArgumentParser._parse_known_argscCs�g}x�|D]�}|s"|d|jkr.|j|�q
ylt|dd���R}g}x2|j�j�D]"}x|j|�D]}|j|�qdWqTW|j|�}|j|�WdQRXWq
tk
r�t	j
�d}|jt|��Yq
Xq
W|S)NrrO)
rDrr��readr��convert_arg_line_to_argsrhr�rr�rQr<r�)r!r"Znew_arg_stringsrlZ	args_file�arg_liner#rRr&r&r'rh�s 

z$ArgumentParser._read_args_from_filescCs|gS)Nr&)r!rpr&r&r'ro�sz'ArgumentParser.convert_arg_line_to_argscCst|j|�}tj||�}|dkrfdtd�ttd�ttd�i}tdd|j�|j}|j|j|�}t	||��t
|jd��S)Nzexpected one argumentzexpected at most one argumentzexpected at least one argumentzexpected %s argumentzexpected %s argumentsrO)�_get_nargs_patternrGr/r}r
rrr�r�rrir�)r!rora�
nargs_patternr/Znargs_errorsr�r�r&r&r'rZs

zArgumentParser._match_argumentcstg}xjtt|�dd�D]V}|d|�}dj�fdd�|D��}tj||�}|dk	r|jdd�|j�D��PqW|S)NrrOrYcsg|]}�j|��qSr&)rq)rUro)r!r&r'rXsz;ArgumentParser._match_arguments_partial.<locals>.<listcomp>cSsg|]}t|��qSr&)ri)rUrr&r&r'rX!sr�)r�rir rGr/r�rf)r!rerar�r�Z
actions_slicermr/r&)r!r'res
z'ArgumentParser._match_arguments_partialc
Cs|sdS|d|jkrdS||jkr8|j|}||dfSt|�dkrHdSd|kr~|jdd�\}}||jkr~|j|}|||fS|jr�|j|�}t|�dkr�djdd�|D��}||d�}td�}|j||�nt|�dkr�|\}	|	S|j	j
|��r|j�sdSd	|k�rdSd|dfS)
NrrO�=z, cSsg|]\}}}|�qSr&r&)rUror�r]r&r&r'rXGsz2ArgumentParser._parse_optional.<locals>.<listcomp>)r5Zmatchesz4ambiguous option: %(option)s could match %(matches)srv)rrri�splitrF�_get_option_tuplesr r}r<rr/r)
r!rlror�r]Z
option_tuplesZoptionsrWr�r\r&r&r'rj's>










zArgumentParser._parse_optionalc
Cs0g}|j}|d|kr~|d|kr~d|kr<|jdd�\}}n|}d}x�|jD],}|j|�rL|j|}|||f}|j|�qLWn�|d|ko�|d|k�r|}d}|dd�}|dd�}	xr|jD]T}||kr�|j|}|||	f}|j|�q�|j|�r�|j|}|||f}|j|�q�Wn|jtd�|�|S)NrrOrsr2zunexpected option string: %s)rrtr�
startswithrr<r})
r!r�r�r'Z
option_prefixr]ror�Zshort_option_prefixZshort_explicit_argr&r&r'rubs8







z!ArgumentParser._get_option_tuplescCs�|j}|dkrd}nX|tkr"d}nJ|tkr0d}n<|tkr>d}n.|tkrLd}n |tkrZd}nddjd	|�}|jr�|jdd
�}|jdd
�}|S)Nz(-*A-*)z(-*A?-*)z	(-*[A-]*)z
(-*A[A-]*)z([-AO]*)z(-*A[-AO]*)z(-*%s-*)z-*rSrYr�)	r�r
rrrrr rr7)r!ror�rrr&r&r'rq�s$z!ArgumentParser._get_nargs_patterncsx�jttgkr2y|jd�Wntk
r0YnX|rz�jtkrz�jrP�j}n�j}t	|t
�rx�j�|�}�j�|�n�|r��jt
kr��jr��jdk	r��j}n|}�j�|�n�t|�dkr�jdtgkr�|\}�j�|�}�j�|�n��jtk�r��fdd�|D�}nb�jtk�rD��fdd�|D�}�j�|d�n0��fdd�|D�}x|D]}�j�|��q^W|S)Nz--rOcsg|]}�j�|��qSr&)rk)rU�v)ror!r&r'rX�sz.ArgumentParser._get_values.<locals>.<listcomp>csg|]}�j�|��qSr&)rk)rUrw)ror!r&r'rX�srcsg|]}�j�|��qSr&)rk)rUrw)ror!r&r'rX�s)r�rrr0r:r
rr�r�r�r�rk�_check_valuerri)r!ror"r%rlrwr&)ror!r'rU�s>


zArgumentParser._get_valuescCs�|jd|j|j�}t|�s0td�}t|||��y||�}Wn�tk
r~t|jdt|j��}tt	j
�d�}t||��YnLttfk
r�t|jdt|j��}||d�}td�}t|||��YnX|S)Nrz%r is not callablerrO)rr%z!invalid %(type)s value: %(value)r)
rrr$r}rrr.rr�r�rQr%r:)r!rorlr(r�r�r$rWr&r&r'rk�s 
zArgumentParser._get_valuecCsF|jdk	rB||jkrB|djtt|j��d�}td�}t|||��dS)Nz, )r%r�z3invalid choice: %(value)r (choose from %(choices)s))r�r �maprr}r)r!ror%rWr�r&r&r'rx	s
zArgumentParser._check_valuecCs$|j�}|j|j|j|j�|j�S)N)r�rhrdrrr\)r!rRr&r&r'�format_usage	szArgumentParser.format_usagecCsx|j�}|j|j|j|j�|j|j�x:|jD]0}|j|j	�|j|j�|j
|j�|j�q0W|j|j
�|j�S)N)r�rhrdrrrbr
rr^r2rrr�r_rBr\)r!rRZaction_groupr&r&r'r\	szArgumentParser.format_helpcCs|j|jd�S)N)rL)rCrL)r!r&r&r'r�0	szArgumentParser._get_formattercCs"|dkrtj}|j|j�|�dS)N)r�r�r�rz)r!�filer&r&r'�print_usage6	szArgumentParser.print_usagecCs"|dkrtj}|j|j�|�dS)N)r�r�r�r\)r!r{r&r&r'r�;	szArgumentParser.print_helpcCs |r|dkrtj}|j|�dS)N)r��stderr�write)r!r�r{r&r&r'r�@	szArgumentParser._print_messagercCs |r|j|tj�tj|�dS)N)r�r�r}r�)r!Zstatusr�r&r&r'r�I	szArgumentParser.exitcCs0|jtj�|j|d�}|jdtd�|�dS)N)rLr�r2z%(prog)s: error: %(message)s
)r|r�r}rLr�r})r!r�rWr&r&r'r<N	s	zArgumentParser.error)NN)NN)N)N)N)rN) rr,r-rrNrrLr&rMrKrNr�rOrhrorZrerjrurqrUrkrxrzr\r�r|r�r�r�r<r�r&r&)r�r'r1sN4

#w;,,4


	
)5�__version__�__all__�collectionsr�r�r��osr7�rerG�sysr��textwrapr�rr}rrr
rrrrr�r�rr1rrrrr	r��	Exceptionrrrr�r�r�r�r�r�r�r�r�r�rr
r	r)r+rr&r&r&r'�<module>@s~
n
	[#%`65"