???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................3

  \xE                 @   s   d dl Z d dlZd dlZd dlZd dlT dZejde Zejdeef Ze	j
ddZG dd	 d	Zd
d Zdd ejD Zdd Zdd ZG dd dZedkrdZx2dD ]*Zede  edjeee e  qW dS )    N)*z[a-zA-Z](?:[a-zA-Z0-9-]*)z^%s$z^(%s)=!(%s)$-_c               @   s   e Zd ZdddZdd Zdd Zddd	Zd
d Zdd Zdd Z	dd Z
dd Zdd Zd ddZdd Zd!ddZd"ddZdS )#FancyGetoptNc             C   sN   || _ i | _| j r| j  i | _i | _g | _g | _i | _i | _i | _	g | _
d S )N)option_tableoption_index_build_indexaliasnegative_alias
short_opts	long_opts
short2long	attr_name	takes_argoption_order)selfr    r   ./usr/lib64/python3.6/distutils/fancy_getopt.py__init__)   s    	zFancyGetopt.__init__c             C   s,   | j j  x| jD ]}|| j |d < qW d S )Nr   )r   clearr   )r   optionr   r   r   r   Q   s    
zFancyGetopt._build_indexc             C   s   || _ | j  d S )N)r   r   )r   r   r   r   r   set_option_tableV   s    zFancyGetopt.set_option_tablec             C   s<   || j krtd| n |||f}| jj| || j |< d S )Nz'option conflict: already an option '%s')r   DistutilsGetoptErrorr   append)r   long_optionZshort_optionZhelp_stringr   r   r   r   
add_optionZ   s    

zFancyGetopt.add_optionc             C   s
   || j kS )N)r   )r   r   r   r   r   
has_optionc   s    zFancyGetopt.has_optionc             C   s
   |j tS )N)	translatelongopt_xlate)r   r   r   r   r   get_attr_nameh   s    zFancyGetopt.get_attr_namec             C   sR   xL|j  D ]@\}}|| jkr.td|||f || jkr
td|||f q
W d S )Nz(invalid %s '%s': option '%s' not definedz0invalid %s '%s': aliased option '%s' not defined)itemsr   r   )r   aliasesZwhatr	   optr   r   r   _check_alias_dictn   s    

zFancyGetopt._check_alias_dictc             C   s   | j |d || _d S )Nr	   )r#   r	   )r   r	   r   r   r   set_aliasesx   s    zFancyGetopt.set_aliasesc             C   s   | j |d || _d S )Nznegative alias)r#   r
   )r   r
   r   r   r   set_negative_aliases}   s    z FancyGetopt.set_negative_aliasesc             C   s  g | _ g | _| jj  i | _x| jD ]}t|dkrH|\}}}d}n(t|dkrb|\}}}}ntd|f t|t	 st|dk rt
d| |d kpt|t	ot|dkst
d| || j|< | j j| |d d	kr|r|d
 }|dd }d| j|< nF| jj|}|d k	rB| j| r8t
d||f || j d< d| j|< | jj|}|d k	r| j| | j| krt
d||f tj|st
d| | j|| j|< |r&| jj| || j|d < q&W d S )N   r      zinvalid 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 onlyr,   r,   )r   r   r   r   repeatr   len
ValueError
isinstancestrr   r   r   r
   getr	   
longopt_rematchr   r   )r   r   longshorthelpr-   Zalias_tor   r   r   _grok_option_table   s^    


 



zFancyGetopt._grok_option_tablec             C   sr  |d krt jdd  }|d kr*t }d}nd}| j  dj| j}ytj||| j\}}W n, tjk
r } zt	|W Y d d }~X nX x|D ]\}}t
|dkr|d dkr| j|d  }n|dd  }| jj|}	|	r|	}| j| s
| jj|}	|	r|	}d}nd}| j| }
|r<| jj|
d k	r<t||
dd }t||
| | jj||f qW |rj||fS |S d S )Nr)   TF r(   r   r   )sysargvOptionDummyr8   joinr   getoptr   errorZDistutilsArgErrorr.   r   r	   r2   r   r
   r   r-   getattrsetattrr   r   )r   argsobjectZcreated_objectr   Zoptsmsgr"   valr	   attrr   r   r   r>      sB    
zFancyGetopt.getoptc             C   s   | j d krtdn| j S d S )Nz!'getopt()' hasn't been called yet)r   RuntimeError)r   r   r   r   get_option_order  s    

zFancyGetopt.get_option_orderc             C   sx  d}xV| j D ]L}|d }|d }t|}|d dkr<|d }|d k	rL|d }||kr|}qW |d d d }d}|| }	d| }
|r|g}ndg}x| j D ]}|d d	 \}}}t||	}|d dkr|dd }|d kr| r|jd
|||d f  n|jd||f  n:d||f }|r<|jd
|||d f  n|jd|  x$|dd  D ]}|j|
|  qXW qW |S )Nr   r)   r*      r(   N   r9   zOption summary:r&   z  --%-*s  %sz
  --%-*s  z%s (-%s)z  --%-*sr,   r,   r,   )r   r.   	wrap_textr   )r   headerZmax_optr   r5   r6   lZ	opt_widthZ
line_widthZ
text_widthZ
big_indentlinesr7   textZ	opt_namesr   r   r   generate_help  sF    

zFancyGetopt.generate_helpc             C   s4   |d krt j}x | j|D ]}|j|d  qW d S )N
)r:   stdoutrP   write)r   rL   fileliner   r   r   
print_helph  s    zFancyGetopt.print_help)N)NN)NN)N)NN)__name__
__module____qualname__r   r   r   r   r   r   r#   r$   r%   r8   r>   rH   rP   rV   r   r   r   r   r      s   
(
	
M
=

Or   c             C   s   t | }|j| |j||S )N)r   r%   r>   )optionsZnegative_optrC   rB   parserr   r   r   fancy_getopto  s    
r\   c             C   s   i | ]}d t |qS )r9   )ord).0Z_wscharr   r   r   
<dictcomp>u  s    r_   c             C   s"  | d krg S t | |kr| gS | j } | jt} tjd| }dd |D }g }x|rg }d}xZ|rt |d }|| |kr|j|d  |d= || }q`|r|d d dkr|d	= P q`W |r
|dkr|j|d d|  |d |d  |d< |d d dkr
|d= |jdj| qPW |S )
Nz( +|-+)c             S   s   g | ]}|r|qS r   r   )r^   Zchr   r   r   
<listcomp>  s    zwrap_text.<locals>.<listcomp>r   r)   r9    r,   r,   )r.   
expandtabsr   WS_TRANSresplitr   r=   )rO   widthZchunksrN   Zcur_lineZcur_lenrM   r   r   r   rK   w  s:    

rK   c             C   s
   | j tS )N)r   r   )r"   r   r   r   translate_longopt  s    rg   c               @   s   e Zd Zg fddZdS )r<   c             C   s   x|D ]}t | |d  qW d S )N)rA   )r   rZ   r"   r   r   r   r     s    
zOptionDummy.__init__N)rW   rX   rY   r   r   r   r   r   r<     s   r<   __main__zTra-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: %drQ   )ri   rj   rk   rl   )r:   stringrd   r>   Zdistutils.errorsZlongopt_patcompiler3   Zneg_alias_rer1   	maketransr   r   r\   Z
whitespacerc   rK   rg   r<   rW   rO   wprintr=   r   r   r   r   <module>   s(     T6
