-
<c       s    d  Z  	  d Z  d k Z d k Z d k Z  d k T d k Z  d k T d 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 o] d Z xJ d d d d f D]3 Z d e GHe i e e e  d  GHHqP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 2 4 e d  Z _ d   Z d d   Z h e e d  Z r d   Z w d   Z	 ~ d   Z
  d   Z  d	   Z  d
   Z  e e d  Z -d   Z 8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    s   4 = | |  _  A h  |  _ B |  i  o C |  i   n G h  |  _ K h  |  _ Q g  |  _ R g  |  _ S h  |  _ T h  |  _	 U h  |  _
 Z 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    sE   _ ` |  i i   a x( |  i Da ] } b | |  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    d e | |  _  f |  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    sf   h i |  i i |  o j t d |  n6 m | | | f } n |  i i	 |  o | |  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   r t u |  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   w z { 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   ~  t  o t |  t j p t   x | i   D ]t \ } }  |  i	 i
 |  o  t d | | | f  n  |  i	 i
 |  o  t d | | | f  n q7 Wd  S(   Ns(   invalid %s '%s': option '%s' not defineds0   invalid %s '%s': aliased option '%s' not defined(   s	   __debug__s   types   aliasess   DictionaryTypes   AssertionErrors   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    s     g  |  _  g  |  _  |  i i    x|  i D ]}  y  | \ } } } Wn,  t
 j
 o  t d t |   n X t |  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 o?  | o  | d } n  | d	 d !}  d |  i | <n  |  i i |  }  | t j	 oO  |  i | o  t d
 | | f  n  | |  i d < d	 |  i | <n  d	 |  i | < |  i i |  }  | t j	 o<  |  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 Noneis   =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    	)7
 

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 Xx|	 D]v\ } } t |  d j o | d d j o |  i | d } nL t |  d j o | d d !d j o 	| d } n t d |  |  i i |  } | o | } n |  i | of | 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    s7   -12|  i t j o 3t d  n 5|  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]  8;@d }
 Ax |  i DA] } B| d } C| d } Dt |  }	 E| d d j o F|	 d }	 n G| t j	 o H|	 d }	 n I|	 |
 j o J|	 }
 n q WL|
 d d d } dd } e| | } fd | } g| o h| g } n jd	 g } lx9|  i Dl]+\ } } } nt | |  } o| d d j o p| d d !} n s| t j oM t| o% u| i d
 |
 | | d f  n w| i d |
 | f  nW |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   is   =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    s[   | t j o t i } n x. |  i |  D] } | i | d  q6 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    s9   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  } xQ| oFg  } d } x | o t | d  } | | | j o/ | i | d  | d =| | } n2 | o | d d d j o | d =n Pq W| on | d j o4 | 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    is    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    s4   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%=	 	