-í
ì¶<c       sG  d  Z  d Z d k Z d k Z d k Z d k Td k Z d k Td Z e i	 d e ƒ Z
 e i	 d e e f ƒ Z e i d d ƒ Z e Z d	 f  d
 „  ƒ  YZ d „  Z e i e i d e e i ƒ ƒ Z d „  Z d „  Z d f  d „  ƒ  YZ e d j oK d Z x> d d d d f D]* Z d e GHe i e e e ƒ d ƒ GHHqWn d S(   s6  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
s<   $Id: fancy_getopt.py,v 1.20 2001/12/06 20:51:35 fdrake Exp $N(   s   *s   [a-zA-Z](?:[a-zA-Z0-9-]*)s   ^%s$s   ^(%s)=!(%s)$s   -s   _s   FancyGetoptc      s¤   t  Z d  Z e d „ Z d „  Z d „  Z e e d „ Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z d
 „  Z e e d „ Z d „  Z e d „ Z e e d „ Z RS(   sÕ  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
    c    sv   | |  _  h  |  _ |  i  o |  i ƒ  n h  |  _ h  |  _ g  |  _ g  |  _ h  |  _ h  |  _	 h  |  _
 g  |  _ d  S(   N(   s   option_tables   selfs   option_indexs   _build_indexs   aliass   negative_aliass
   short_optss	   long_optss
   short2longs	   attr_names	   takes_args   option_order(   s   selfs   option_table(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   __init__4 s    			
							c    s6   |  i i ƒ  x" |  i D] } | |  i | d <q Wd  S(   Ni    (   s   selfs   option_indexs   clears   option_tables   option(   s   selfs   option(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   _build_index_ s    
 c    s   | |  _  |  i ƒ  d  S(   N(   s   option_tables   selfs   _build_index(   s   selfs   option_table(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   set_option_tabled s    	c    sT   |  i i | ƒ o t d | ‚ n- | | | f } |  i i	 | ƒ | |  i | <d  S(   Ns'   option conflict: already an option '%s'(
   s   selfs   option_indexs   has_keys   long_options   DistutilsGetoptErrors   short_options   help_strings   options   option_tables   append(   s   selfs   long_options   short_options   help_strings   option(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys
   add_optionh s
    c    s   |  i i | ƒ Sd S(   sc   Return true if the option table for this parser has an
        option with long name 'long_option'.N(   s   selfs   option_indexs   has_keys   long_option(   s   selfs   long_option(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys
   has_optionr s     c    s   t  i | t ƒ Sd S(   s’   Translate long option name 'long_option' to the form it
        has as an attribute of some object: ie., translate hyphens
        to underscores.N(   s   strings	   translates   long_options   longopt_xlate(   s   selfs   long_option(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   get_attr_namew s     c    s}   xv | i ƒ  D]h \ } } |  i i | ƒ o t d | | | f ‚ n |  i i | ƒ o t d | | | f ‚ n q Wd  S(   Ns(   invalid %s '%s': option '%s' not defineds0   invalid %s '%s': aliased option '%s' not defined(	   s   aliasess   itemss   aliass   opts   selfs   option_indexs   has_keys   DistutilsGetoptErrors   what(   s   selfs   aliasess   whats   opts   alias(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   _check_alias_dict~ s      c    s   |  i | d ƒ | |  _ d S(   s'   Set the aliases for this option parser.s   aliasN(   s   selfs   _check_alias_dicts   alias(   s   selfs   alias(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   set_aliasesŠ s     c    s   |  i | d ƒ | |  _ d S(   sÚ   Set 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.s   negative aliasN(   s   selfs   _check_alias_dicts   negative_alias(   s   selfs   negative_alias(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   set_negative_aliases s     c    so  g  |  _ g  |  _ |  i i ƒ  xI|  i D]>} y | \ } } } Wn& t
 j
 o t d t | ƒ ‚ n Xt | ƒ t j	 p t | ƒ d j  o t d | ‚ n | t j p# t | ƒ t j o t | ƒ d j o t d | ‚ n |  i i | ƒ | d d j o3 | o | d } n | d	 d !} d |  i | <np |  i i | ƒ } | t j	 oC |  i | o t d
 | | f ‚ n | |  i d <d	 |  i | <n d	 |  i | <|  i i | ƒ } | t j	 o6 |  i | |  i | j o t d | | f ‚ n n t i | ƒ o t d d | ‚ n |  i | ƒ |  i | <| o% |  i i | ƒ | |  i | d	 <n q) Wd S(   s   Populate the various data structures that keep tabs on the
        option table.  Called by 'getopt()' before it can do anything
        worthwhile.
        s   invalid option tuple i   s9   invalid long option '%s': must be a string of length >= 2i   s:   invalid short option '%s': must a single character or Noneiÿÿÿÿs   =s   :i    s>   invalid negative alias '%s': aliased option '%s' takes a valuesg   invalid alias '%s': inconsistent with aliased option '%s' (one of them takes a value, the other doesn'ts   invalid long option name '%s' s'   (must be letters, numbers, hyphens onlyN(   s   selfs	   long_optss
   short_optss
   short2longs   clears   option_tables   options   longs   shorts   helps
   ValueErrors   DistutilsGetoptErrors   strs   types
   StringTypes   lens   Nones   appends	   takes_args   negative_aliass   gets   alias_tos   aliass
   longopt_res   matchs   get_attr_names	   attr_name(   s   selfs   shorts   options   alias_tos   longs   help(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   _grok_option_table˜ sJ     		
 &4 
c    s  | t j o t i d } n | t j o t ƒ  } d } n d } |  i ƒ  t	 i
 |  i ƒ } y" t i | | |  i ƒ \ }	 } Wn! t i j
 o } t | ‚ n XxE|	 D]=\ } } t | ƒ d j o | d d j o |  i | d } nC t | ƒ d j o | d d !d j o | d } n t d | ‚ |  i i | ƒ } | o
 | } n |  i | oQ | d j o t d | ‚ n |  i i | ƒ } | o | } d } n d } n |  i | }
 t | |
 | ƒ |  i i | | f ƒ q­ W| o | | f Sn | Sd	 S(
   s  Parse the command-line options in 'args' and store the results
        as attributes of '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.
        i   i    i   s   -s   --s)   this can't happen: bad option string '%s's    s(   this can't happen: bad option value '%s'N(    s   argss   Nones   syss   argvs   objects   OptionDummys   created_objects   selfs   _grok_option_tables   strings   joins
   short_optss   getopts	   long_optss   optss   errors   msgs   DistutilsArgErrors   opts   vals   lens
   short2longs   DistutilsInternalErrors   aliass   gets	   takes_args   negative_aliass	   attr_names   attrs   setattrs   option_orders   append(   s   selfs   argss   objects   opts   aliass   msgs   vals   created_objects
   short_optss   optss   attr(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   getoptê sJ    	 	

" $'


c    s(   |  i t j o t d ‚ n |  i Sd S(   s«   Returns the list of (option, value) tuples processed by the
        previous run of 'getopt()'.  Raises RuntimeError if
        'getopt()' hasn't been called yet.
        s!   'getopt()' hasn't been called yetN(   s   selfs   option_orders   Nones   RuntimeError(   s   self(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   get_option_order-s     c    së  d }
 x‚ |  i D]w } | d } | d } t | ƒ }	 | d d j o |	 d }	 n | t j	 o |	 d }	 n |	 |
 j o
 |	 }
 n q W|
 d d d } d } | | } d | } | o | g } n
 d	 g } x|  i D]\ } } } t | | ƒ } | d d j o | d d !} n | t j oD | o" | i d
 |
 | | d f ƒ n | i d |
 | f ƒ nK d | | f } | o" | i d
 |
 | | d f ƒ n | i d | ƒ x# | d D] }	 | i | |	 ƒ qÄWqÞ W| Sd S(   sŒ   Generate help text (a list of strings, one per suggested line of
        output) from the option table for this FancyGetopt object.
        i    i   iÿÿÿÿs   =i   i   iN   s    s   Option summary:s     --%-*s  %ss
     --%-*s  s   %s (-%s)s     --%-*sN(   s   max_opts   selfs   option_tables   options   longs   shorts   lens   ls   Nones	   opt_widths
   line_widths
   text_widths
   big_indents   headers   liness   helps	   wrap_texts   texts   appends	   opt_names(   s   selfs   headers
   line_widths   shorts   options	   opt_namess
   big_indents   texts   liness   ls   max_opts	   opt_widths   longs
   text_widths   help(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   generate_help8sJ     
 



	
 "" c    sI   | t j o t i } n x( |  i | ƒ D] } | i | d ƒ q* Wd  S(   Ns   
(	   s   files   Nones   syss   stdouts   selfs   generate_helps   headers   lines   write(   s   selfs   headers   files   line(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys
   print_helpŒs
     (   s   __name__s
   __module__s   __doc__s   Nones   __init__s   _build_indexs   set_option_tables
   add_options
   has_options   get_attr_names   _check_alias_dicts   set_aliasess   set_negative_aliasess   _grok_option_tables   getopts   get_option_orders   generate_helps
   print_help(    (    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   FancyGetopt( s   
 +		
							RC	Tc    s-   t  |  ƒ } | i | ƒ | i | | ƒ Sd  S(   N(   s   FancyGetopts   optionss   parsers   set_negative_aliasess   negative_opts   getopts   argss   object(   s   optionss   negative_opts   objects   argss   parser(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   fancy_getopt•s    s    c    s›  |  t j o g  Sn t |  ƒ | j o |  g Sn t i |  ƒ }  t i |  t ƒ }  t i	 d |  ƒ } t t | ƒ } g  } x| og  } d } x{ | os t | d ƒ } | | | j o& | i | d ƒ | d =| | } n) | o | d d d j o | d =n Pq” W| o_ | d j o. | i | d d | !ƒ | d | | d <n | d d d j o | d =n n | i t i | d ƒ ƒ q~ W| Sd S(   s¶   wrap_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.
    s   ( +|-+)i    iÿÿÿÿs    s    N(   s   texts   Nones   lens   widths   strings
   expandtabss	   translates   WS_TRANSs   res   splits   chunkss   filters   liness   cur_lines   cur_lens   ls   appends   join(   s   texts   widths   liness   ls   cur_lines   chunkss   cur_len(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys	   wrap_texts@       c    s   t  i |  t ƒ Sd S(   sX   Convert a long option name to a valid Python identifier by
    changing "-" to "_".
    N(   s   strings	   translates   opts   longopt_xlate(   s   opt(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   translate_longoptÚs     s   OptionDummyc      s   t  Z d  Z g  d „ Z RS(   s_   Dummy class just used as a place to hold command-line option
    values as instance attributes.c    s%   x | D] } t |  | t ƒ q Wd S(   sk   Create a new OptionDummy instance.  The attributes listed in
        'options' will be initialized to None.N(   s   optionss   opts   setattrs   selfs   None(   s   selfs   optionss   opt(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   __init__ås      (   s   __name__s
   __module__s   __doc__s   __init__(    (    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   OptionDummyás    s   __main__s¢   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?"].)i
   i   i   i(   s	   width: %ds   
(   s   __doc__s   __revision__s   syss   strings   res   typess   getopts   distutils.errorss   longopt_pats   compiles
   longopt_res   neg_alias_res	   maketranss   longopt_xlates   Nones   _option_orders   FancyGetopts   fancy_getopts
   whitespaces   lens   WS_TRANSs	   wrap_texts   translate_longopts   OptionDummys   __name__s   texts   ws   join(   s   WS_TRANSs   __revision__s   _option_orders   strings   OptionDummys
   longopt_res   texts   translate_longopts   syss   res   FancyGetopts   longopt_pats   neg_alias_res   ws   longopt_xlates   getopts	   wrap_texts   fancy_getopt(    (    s,   /usr/lib/python2.2/distutils/fancy_getopt.pys   ?	 s0   	ÿ n	"	=	 	