‡Æ
5Oö9c       sI  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 oM d Z x@ d d d d f d r* 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.18 2000/09/26 02:06:03 gward Exp $N(   s   *s   [a-zA-Z](?:[a-zA-Z0-9-]*)s   ^%s$s   ^(%s)=!(%s)$s   -s   _s   FancyGetoptc      sž   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_tables3   /mit/python/lib/python2.0/distutils/fancy_getopt.pys   __init__4 s    			
							c    s8   |  i i ƒ  x$ |  i d r } | |  i | d <q Wd  S(   Ni    (   s   selfs   option_indexs   clears   option_tables   option(   s   selfs   options3   /mit/python/lib/python2.0/distutils/fancy_getopt.pys   _build_index_ s     c    s   | |  _  |  i ƒ  d  S(   N(   s   option_tables   selfs   _build_index(   s   selfs   option_tables3   /mit/python/lib/python2.0/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   options3   /mit/python/lib/python2.0/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_options3   /mit/python/lib/python2.0/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_options3   /mit/python/lib/python2.0/distutils/fancy_getopt.pys   get_attr_namew s     c    s   xx | i ƒ  d rh \ } } |  i i | ƒ o t d | | | f ‚ n |  i i | ƒ o t d | | | f ‚ n q Wd  S(   Ni    s(   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   aliass   opts3   /mit/python/lib/python2.0/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   aliass3   /mit/python/lib/python2.0/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_aliass3   /mit/python/lib/python2.0/distutils/fancy_getopt.pys   set_negative_aliases s     c    st  g  |  _ g  |  _ |  i i ƒ  xN|  i d rA} 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 o4 | o | d } n | d d !} d |  i | <nq |  i i | ƒ } | t j	 oD |  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.
        i    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 Nones   =s   :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   options   longs   shorts   helps   alias_tos3   /mit/python/lib/python2.0/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 XxG| d r=\ } } 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 t ‚ 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   values   negative_aliass	   attr_names   attrs   setattrs   option_orders   append(   s   selfs   argss   objects   created_objects
   short_optss   optss   msgs   opts   vals   aliass   attrs3   /mit/python/lib/python2.0/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   selfs3   /mit/python/lib/python2.0/distutils/fancy_getopt.pys   get_option_order-s     c    sô  d } x… |  i d rx } | 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 r\ } } } 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 r } | 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   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   max_opts   options   longs   shorts   ls	   opt_widths
   line_widths
   text_widths
   big_indents   liness   helps   texts	   opt_namess3   /mit/python/lib/python2.0/distutils/fancy_getopt.pys   generate_help8sJ      



	 "" c    sK   | t j o t i } n x* |  i | ƒ d r } | i | d ƒ q, Wd  S(   Ni    s   
(	   s   files   Nones   syss   stdouts   selfs   generate_helps   headers   lines   write(   s   selfs   headers   files   lines3   /mit/python/lib/python2.0/distutils/fancy_getopt.pys
   print_helpŒs
     (   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(    s3   /mit/python/lib/python2.0/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   parsers3   /mit/python/lib/python2.0/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} | ou 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   chunkss   liness   cur_lines   cur_lens   ls3   /mit/python/lib/python2.0/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   opts3   /mit/python/lib/python2.0/distutils/fancy_getopt.pys   translate_longoptÚs     s   OptionDummyc      s   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 r } t |  | t ƒ q	 Wd S(   sk   Create a new OptionDummy instance.  The attributes listed in
        'options' will be initialized to None.i    N(   s   optionss   opts   setattrs   selfs   None(   s   selfs   optionss   opts3   /mit/python/lib/python2.0/distutils/fancy_getopt.pys   __init__ås     	 (   s   __doc__s   __init__(    s3   /mit/python/lib/python2.0/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(   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(    s3   /mit/python/lib/python2.0/distutils/fancy_getopt.pys   ?	 s0   	ÿ n	"	=	 	