£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>

i fxE                 @   sK  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Td Z e j d e  Z e j d e e f  Z	 e
 j d d  Z Gd	 d
   d
  Z d d   Z d d   e j D Z d d   Z d d   Z Gd d   d  Z e d k rGd Z xK d d d d f D]7 Z e d e  e d j e e e    e   q	Wn  d S)a6  distutils.fancy_getopt

Wrapper around the standard getopt module that provides the following
additional features:
  * short and long options are tied together
  * options have help strings, so fancy_getopt could potentially
    create a complete usage summary
  * options set attributes of a passed-in object
    N)*z[a-zA-Z](?:[a-zA-Z0-9-]*)z^%s$z^(%s)=!(%s)$-_c               @   s   e  Z d  Z d Z d d d  Z d d   Z d d   Z d 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 d  Z d d   Z d d d  Z d d d d  Z d S)FancyGetopta  Wrapper around the standard 'getopt()' module that provides some
    handy extra functionality:
      * short and long options are tied together
      * options have help strings, and help text can be assembled
        from them
      * options set attributes of a passed-in object
      * boolean options can have "negative aliases" -- eg. if
        --quiet is the "negative alias" of --verbose, then "--quiet"
        on the command line sets 'verbose' to false
    Nc             C   st   | |  _  i  |  _ |  j  r( |  j   n  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   ;/opt/alt/python34/lib64/python3.4/distutils/fancy_getopt.py__init__)   s    											zFancyGetopt.__init__c             C   s6   |  j  j   x" |  j D] } | |  j  | d <q Wd  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   sR   | |  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)zcReturn true if the option table for this parser has an
        option with long name 'long_option'.)r   )r   r   r   r   r   
has_optionc   s    zFancyGetopt.has_optionc             C   s   | j  t  S)zTranslate long option name 'long_option' to the form it
        has as an attribute of some object: ie., translate hyphens
        to underscores.)	translatelongopt_xlate)r   r   r   r   r   get_attr_nameh   s    zFancyGetopt.get_attr_namec             C   sw   xp | j    D]b \ } } | |  j k rD t d | | | f   n  | |  j k r t d | | | f   q q Wd  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)z'Set the aliases for this option parser.r	   N)r#   r	   )r   r	   r   r   r   set_aliasesx   s    zFancyGetopt.set_aliasesc             C   s   |  j  | d  | |  _ d S)zSet the negative aliases for this option parser.
        'negative_alias' should be a dictionary mapping option names to
        option names, both the key and value must already be defined
        in the option table.znegative aliasN)r#   r
   )r   r
   r   r   r   set_negative_aliases}   s    z FancyGetopt.set_negative_aliasesc             C   s  g  |  _  g  |  _ |  j j   i  |  _ xa|  j D]V} t |  d k rb | \ } } } d } n: t |  d k r | \ } } } } n t d | f   t | t	  s t |  d k  r t
 d |   n  | d k p t | t	  o t |  d k st
 d	 |   n  | |  j | <|  j  j |  | d d
 k rq| rQ| d } n  | d d  } d |  j | <na |  j j |  } | d k	 r|  j | rt
 d | | f   n  | |  j  d <n  d |  j | <|  j j |  } | d k	 r&|  j | |  j | k r&t
 d | | f   q&n  t j |  sHt
 d |   n  |  j |  |  j | <| r2 |  j j |  | |  j | d <q2 q2 Wd S)zPopulate the various data structures that keep tabs on the
        option table.  Called by 'getopt()' before it can do anything
        worthwhile.
           r      zinvalid option tuple: %r   z9invalid long option '%s': must be a string of length >= 2N   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   s  | d k r" t  j d d  } n  | d k r@ t   } d } n d } |  j   d j |  j  } y" t j | | |  j  \ } } Wn4 t j k
 r } z t	 |   WYd d } ~ Xn Xx"| D]\ } } t
 |  d k r| d d k r|  j | d } n | d d  } |  j j |  }	 |	 r5|	 } n  |  j | sr|  j j |  }	 |	 ri|	 } d } qrd } n  |  j | }
 | r|  j j |
  d k	 rt | |
 d  d } n  t | |
 |  |  j j | | f  q W| r| | f S| Sd S)	a  Parse command-line options in args. Store as attributes on object.

        If 'args' is None or not supplied, uses 'sys.argv[1:]'.  If
        'object' is None or not supplied, creates a new OptionDummy
        object, stores option values there, and returns a tuple (args,
        object).  If 'object' is supplied, it is modified in place and
        'getopt()' just returns 'args'; in both cases, the returned
        'args' is a modified copy of the passed-in 'args' list, which
        is left untouched.
        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  Sd S)zReturns the list of (option, value) tuples processed by the
        previous run of 'getopt()'.  Raises RuntimeError if
        'getopt()' hasn't been called yet.
        Nz!'getopt()' hasn't been called yet)r   RuntimeError)r   r   r   r   get_option_order  s    zFancyGetopt.get_option_orderc             C   s  d } x| |  j  D]q } | d } | d } t |  } | d d k rS | d } n  | d k	 rl | d } n  | | k r | } q q W| d d d } d } | | }	 d | }
 | r | g } n	 d	 g } x|  j  D]} | d d
  \ } } } t | |	  } | d d k r'| d d  } n  | d k rt| rZ| j d | | | d f  q| j d | | f  nH d | | f } | r| j d | | | d f  n | j d |  x) | d d  D] } | j |
 |  qWq W| S)zGenerate help text (a list of strings, one per suggested line of
        output) from the option table for this FancyGetopt object.
        r   r)   r*   N   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   sG   | d  k r t  j } n  x( |  j |  D] } | j | d  q( Wd  S)N
)r:   stdoutrP   write)r   rL   fileliner   r   r   
print_helph  s    zFancyGetopt.print_help)__name__
__module____qualname____doc__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  St  |   | k r) |  g S|  j   }  |  j t  }  t j d |   } d d   | D } g  } x| r}g  } d } xt | r t  | d  } | | | k r | j | d  | d =| | } q | r | d	 d d k r | d
 =n  Pq W| rd| d k rC| j | d d |   | d | d  | d <n  | d d d k rd| d =qdn  | j d j |   qr W| S)zwrap_text(text : string, width : int) -> [string]

    Split 'text' into multiple lines of no more than 'width' characters
    each, and return the list of strings that results.
    Nz( +|-+)c             S   s   g  |  ] } | r |  q Sr   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)zXConvert a long option name to a valid Python identifier by
    changing "-" to "_".
    )r   r   )r"   r   r   r   translate_longopt  s    rh   c               @   s%   e  Z d  Z d Z g  d d  Z d S)r<   z_Dummy class just used as a place to hold command-line option
    values as instance attributes.c             C   s%   x | D] } t  |  | d  q Wd S)zkCreate a new OptionDummy instance.  The attributes listed in
        'options' will be initialized to None.N)rA   )r   r[   r"   r   r   r   r     s    zOptionDummy.__init__N)rW   rX   rY   rZ   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   )rZ   r:   stringre   r>   Zdistutils.errorsZlongopt_patcompiler3   Zneg_alias_rer1   	maketransr   r   r]   Z
whitespacerd   rK   rh   r<   rW   rO   wprintr=   r   r   r   r   <module>	   s(   $
 S6