Your IP : 3.12.34.96


Current Path : /opt/alt/python35/lib64/python3.5/distutils/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/distutils/__pycache__/fancy_getopt.cpython-35.opt-2.pyc



���]xE�@sBddlZddlZddlZddlZddlTdZejde�Zejdeef�Ze	j
dd�ZGdd	�d	�Zd
d�Z
dd
�ejD�Zdd�Zdd�ZGdd�d�Zedkr>dZxKddddfD]7Zede�edjeee���e�qWdS)�N)�*z[a-zA-Z](?:[a-zA-Z0-9-]*)z^%s$z^(%s)=!(%s)$�-�_c@s�eZdZddd�Zdd�Zdd�Zdddd	�Zd
d�Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdddd�Z
dd�Zddd�Zdddd�ZdS)�FancyGetoptNcCsq||_i|_|jr%|j�i|_i|_g|_g|_i|_i|_i|_	g|_
dS)N)�option_table�option_index�_build_index�alias�negative_alias�
short_opts�	long_opts�
short2long�	attr_name�	takes_arg�option_order)�selfr�r�1/opt/alt/python35/lib64/python3.5/fancy_getopt.py�__init__)s				
							zFancyGetopt.__init__cCs6|jj�x"|jD]}||j|d<qWdS)Nr)r�clearr)r�optionrrrrQs
zFancyGetopt._build_indexcCs||_|j�dS)N)rr)rrrrr�set_option_tableVs	zFancyGetopt.set_option_tablecCsR||jkr"td|��n,|||f}|jj|�||j|<dS)Nz'option conflict: already an option '%s')r�DistutilsGetoptErrorr�append)r�long_optionZshort_optionZhelp_stringrrrr�
add_optionZszFancyGetopt.add_optioncCs
||jkS)N)r)rrrrr�
has_optioncszFancyGetopt.has_optioncCs
|jt�S)N)�	translate�
longopt_xlate)rrrrr�
get_attr_namehszFancyGetopt.get_attr_namecCsqxj|j�D]\\}}||jkrAtd|||f��||jkr
td|||f��q
WdS)Nz(invalid %s '%s': option '%s' not definedz0invalid %s '%s': aliased option '%s' not defined)�itemsrr)r�aliasesZwhatr	�optrrr�_check_alias_dictnszFancyGetopt._check_alias_dictcCs|j|d�||_dS)Nr	)r#r	)rr	rrr�set_aliasesxszFancyGetopt.set_aliasescCs|j|d�||_dS)Nznegative alias)r#r
)rr
rrr�set_negative_aliases}sz FancyGetopt.set_negative_aliasescCsug|_g|_|jj�i|_xF|jD];}t|�dkrb|\}}}d}n:t|�dkr�|\}}}}ntd|f��t|t	�s�t|�dkr�t
d|��|dkp�t|t	�o�t|�dkst
d|��||j|<|jj|�|dd	krh|rH|d
}|dd�}d|j|<n[|j
j|�}|dk	r�|j|r�t
d||f��||jd<d|j|<|jj|�}|dk	r|j||j|krt
d||f��tj|�s0t
d
|��|j|�|j|<|r2|jj|�||j|d<q2WdS)N�r�zinvalid option tuple: %r�z9invalid long option '%s': must be a string of length >= 2�z:invalid short option '%s': must a single character or None�=�:z>invalid negative alias '%s': aliased option '%s' takes a valuezginvalid alias '%s': inconsistent with aliased option '%s' (one of them takes a value, the other doesn'tzEinvalid long option name '%s' (must be letters, numbers, hyphens only���r,r,)rrr
r�repeatr�len�
ValueError�
isinstance�strrrrr
�getr	�
longopt_re�matchrr)rr�long�short�helpr-Zalias_torrr�_grok_option_table�s^		
		"
!






zFancyGetopt._grok_option_tablecCs�|dkrtjdd�}|dkr=t�}d}nd}|j�dj|j�}y"tj|||j�\}}Wn4tjk
r�}zt	|��WYdd}~XnXx|D]\}}t
|�dkr|ddkr|j|d}n|dd�}|jj
|�}	|	r/|	}|j|si|jj
|�}	|	rc|	}d}nd}|j|}
|r�|jj
|
�dk	r�t||
d�d}t||
|�|jj||f�q�W|r�||fS|SdS)Nr)TF� r(rr)�sys�argv�OptionDummyr8�joinr�getoptr�errorZDistutilsArgErrorr.r
r	r2rr
rr-�getattr�setattrrr)r�args�objectZcreated_objectrZopts�msgr"�valr	�attrrrrr>�sB		
""
	

zFancyGetopt.getoptcCs)|jdkrtd��n|jSdS)Nz!'getopt()' hasn't been called yet)r�RuntimeError)rrrr�get_option_orderszFancyGetopt.get_option_ordercCs�d}xs|jD]h}|d}|d}t|�}|ddkrP|d}|dk	rf|d}||kr|}qW|ddd}d}||}	d|}
|r�|g}n	dg}x|jD]}|dd	�\}}}t||	�}
|ddkr|dd�}|dkrh|
rN|jd
|||
df�q�|jd||f�nHd||f}|
r�|jd
|||
df�n|jd
|�x)|
dd�D]}|j|
|�q�Wq�W|S)Nrr)r*�r(�Nr9zOption summary:r&z  --%-*s  %sz
  --%-*s  z%s (-%s)z  --%-*sr,r,r,)rr.�	wrap_textr)r�headerZmax_optrr5r6�lZ	opt_widthZ
line_width�
text_widthZ
big_indent�linesr7�textZ	opt_namesrrr�
generate_helpsF






	!	zFancyGetopt.generate_helpcCsD|dkrtj}x(|j|�D]}|j|d�q%WdS)N�
)r:�stdoutrQ�write)rrL�file�linerrr�
print_helphs	zFancyGetopt.print_help)�__name__�
__module__�__qualname__rrrrrrr#r$r%r8r>rHrQrWrrrrrs(	
M=
OrcCs)t|�}|j|�|j||�S)N)rr%r>)�optionsZnegative_optrCrB�parserrrr�fancy_getoptos
r]cCsi|]}dt|��qS)r9)�ord)�.0Z_wscharrrr�
<dictcomp>us	r`cCsv|dkrgSt|�|kr)|gS|j�}|jt�}tjd|�}dd�|D�}g}x|rqg}d}xq|r�t|d�}|||kr�|j|d�|d=||}q�|r�|dddkr�|d	=Pq�W|rX|dkr=|j|dd|��|d|d�|d<|dddkrX|d=|jdj|��qrW|S)
Nz( +|-+)cSsg|]}|r|�qSrr)r_Zchrrr�
<listcomp>�s	zwrap_text.<locals>.<listcomp>rr)r9�r,r,)r.�
expandtabsr�WS_TRANS�re�splitrr=)rP�width�chunksrO�cur_line�cur_lenrMrrrrKws:		
rKcCs
|jt�S)N)rr)r"rrr�translate_longopt�srkc@seZdZgdd�ZdS)r<cCs%x|D]}t||d�qWdS)N)rA)rr[r"rrrr�s
zOptionDummy.__init__N)rXrYrZrrrrrr<�sr<�__main__z�Tra-la-la, supercalifragilisticexpialidocious.
How *do* you spell that odd word, anyways?
(Someone ask Mary -- she'll know [or she'll
say, "How should I know?"].)�
���(z	width: %drR)r:�stringrer>Zdistutils.errorsZlongopt_pat�compiler3Zneg_alias_rer1�	maketransrrr]�
whitespacerdrKrkr<rXrP�w�printr=rrrr�<module>s&$
�S6

?>