-í
U‹<c       s…    d  Z    d Z  d k Z d k Z d k Z d k Z d k Z d k Z d k Z  d „  Z	 . d d „ Z
 : d „  Z D e
 Z F e i d ƒ Z G e i d ƒ Z I e i e e d	 „ Z d e i i e i i e i i e i d
 „ Z { d f  d „  ƒ  YZ ¢ d e f d „  ƒ  YZ ³ d e f d „  ƒ  YZ Ã d f  d „  ƒ  YZ ?e Z Ad „  Z Qe d j o Re ƒ  n d S(   s   CommandLine - Get and parse command line options

    NOTE: This still is very much work in progress !!!

    Different version are likely to be incompatible.

    TODO:

    · Incorporate the changes made by (see Inbox)
    · Add number range option using srange() 

    Copyright (c) 1997-2001, Marc-Andre Lemburg; mailto:mal@lemburg.com
    Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info@egenix.com
    See the documentation for further information on copyrights,
    or contact the author. All Rights Reserved.
s   1.0Nc    sÒ      g  }  g  }   x— |  D  ]Œ } ! | i d j o8 # | i | i ƒ $ | i o % | i d ƒ n n< ( | i o ) | i | i d ƒ n + | i | i ƒ q" W, t i	 | d ƒ | f Sd S(   sP    Convert the option list to a getopt flag string and long opt
        list

    s   -s   :s   =s    N(
   s   ss   ls   optionss   os   prefixs   appends   names   takes_arguments   strings   join(   s   optionss   ss   os   l(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   _getopt_flags s   		
 	s   >>> c    sL   . 3 4 d k  } 5 | i  |  ƒ } 6 | t j o 7 t ‚ n 8 | Sd S(   sw    Get raw input from a terminal without echoing the characters to
        the terminal, e.g. for password queries.

    N(   s   getpasss   prompts   entrys   Nones   KeyboardInterrupt(   s   prompts   getpasss   entry(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   invisible_input. s   c    sA   : = > h  } ? x! |  D? ] } @ | | | i <q WA | Sd S(   sC    Return a dictionary mapping option names to Option instances.
    N(   s   ds   optionss   options   name(   s   optionss   options   d(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   option_dict: s   	
 	s   \s*(-?\d+)\s*$s   \s*(-?\d+)\s*-\s*(-?\d+)\s*$c 
   sç   I V W g  } X | i }	 Y x» | |  d ƒ DY ]§ } Z | i | ƒ } [ | o' \ |	 t | i	 ƒ  d ƒ ƒ ] q. n ^ | i | ƒ } _ | oB ` t t | i	 ƒ  ƒ \ } } a t | | d ƒ | t | ƒ )n q. Wb | Sd S(   sö    Converts a textual representation of integer numbers and ranges
        to a Python list.

        Supported formats: 2,3,4,2-10,-1 - -3, 5 - -2

        Values are appended to the created list in the order specified
        in the string.

    s   ,i    i   N(   s   ls   appends   splits   ss   entrys   integers   matchs   ms   ints   groupss   integerRanges   maps   starts   ends   ranges   len(
   s   ss   splits   integers   integerRanges   ends   starts   ms   ls   entrys   append(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   srangeI s   	 	


(c    s   d n o y p | |  ƒ }  Wn q t j
 o
 r n Xs y t | |  ƒ }  Wn u t j
 o
 v n Xw | | ƒ  |  ƒ Sd S(   s§    Return the corresponding absolute path for path.

        path is expanded in the usual shell ways before
        joining it with the current working directory.

    N(   s
   expandvarss   paths   AttributeErrors
   expandusers   joins   getcwd(   s   paths
   expandvarss
   expandusers   joins   getcwd(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   abspathd s   
s   Optionc      se   { t  Z d  Z  € e Z  d Z ‚ d Z ƒ d Z „ d Z … d Z	 ‡ e d „ Z
 “ d „  Z RS(   s,    Option base class. Takes no argument.

    s    s   -i    i   c    s   ‡ ‰ | d  d j o Š t d ‚ n ‹ | d d !d j o  Œ d |  _  | d |  _  n  | d |  _   | o ‘ | |  _ n d  S(   Ni   s   -s    option names must start with "-"i   s   --(   s   names	   TypeErrors   selfs   prefixs   help(   s   selfs   names   help(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   __init__‡ s   
c    sß   “ • |  } – | i | i } — | i o ˜ | d } n ™ t | ƒ |  i j o- š | d d |  i d t | i ƒ } n œ d |  i | f }  | i } ž | i	 o Ÿ | d | i
 } n   d | | f Sd  S(   Ns    args   
s    i   s   %-*s s    (%s)s   %s %s(   s   selfs   os   prefixs   names   takes_arguments   lens   tabs   helps   descriptions   has_defaults   default(   s   selfs   names   os   description(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   __str__“ s   	-(   s   __name__s
   __module__s   __doc__s   Nones   defaults   helptexts   prefixs   takes_arguments   has_defaults   tabs   __init__s   __str__(    (    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   Option{ s   						s   ArgumentOptionc      s&   ¢ t  Z d  Z ¨ © e e d „ Z RS(   sa    Option that takes an argument.

        An optional default argument can be given.
        
    c    sU   © ¬ t  i |  | | ƒ ® | t j	 o ¯ | |  _ ° d |  _ n ± d |  _ d  S(   Ni   (	   s   Options   __init__s   selfs   names   helps   defaults   Nones   has_defaults   takes_argument(   s   selfs   names   helps   default(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   __init__© s
   (   s   __name__s
   __module__s   __doc__s   Nones   __init__(    (    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   ArgumentOption¢ s   s   SwitchOptionc      s&   ³ t  Z d  Z · ¸ e e d „ Z RS(   sD    Options that can be on or off. Has an optional default value.

    c    sI   ¸ » t  i |  | | ƒ ½ | t j	 o ¾ | |  _ ¿ d |  _ n d  S(   Ni   (   s   Options   __init__s   selfs   names   helps   defaults   Nones   has_default(   s   selfs   names   helps   default(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   __init__¸ s   (   s   __name__s
   __module__s   __doc__s   Nones   __init__(    (    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   SwitchOption³ s   s   Applicationc      s»  Ã t  Z d  Z È Ê g  Z Í e d d ƒ e d d ƒ e d d ƒ e d d ƒ e d d	 ƒ e d
 d ƒ g Z æ d Z é d Z ì d Z ï d Z	 ò d Z
 õ d Z ø d Z d Z d Z d Z 
e Z e Z e d „ Z Nd „  Z Yd „  Z cd d „ Z md „  Z ¸d „  Z Åd d „ Z Þd „  Z åd „  Z ìd „  Z d „  Z 	d „  Z d „  Z d „  Z  d „  Z! d  „  Z" %d! „  Z# 2d" „  Z$ RS(#   sP    Command line application interface with builtin argument
        parsing.

    s   -vs   generate verbose outputs   -hs   show this help texts   --helps   --debugs   enable debuggings   --copyrights   show copyrights
   --exampless   show examples of usages    s   %(name)s [option] files...s6  Copyright (c) 1997-2001, Marc-Andre Lemburg; mailto:mal@lemburg.com
Copyright (c) 2000-2001, eGenix.com Software GmbH; mailto:info@egenix.com
See the documentation for further information on copyrights,
or contact the author. All Rights Reserved.
*** UNAUTHORIZED COPYING, USAGE or DISTRIBUTION PROHIBITED. ***i   i    c    sX  | t j o t i  } n t i i | d ƒ d |  _ |  i o# t i i |  i ƒ d |  _ n |  i |  _ |  i	 o |  i |  _	 n |  i	 |  _	 | d |  _
 !t |  i ƒ |  _ $xB |  i D$]4 } %|  i i | i ƒ o &|  i | ƒ n qå W)g  |  _ ,yŽ .|  i ƒ  } /| t j	 o 0t | ‚ n 3|  i ƒ  } 4| t j	 o 5t | ‚ n 8|  i ƒ  } 9| t j o :d } n Wnˆ <t j
 o } =no ?t j
 o @HAd GHBd } nE DEHFd GHG|  i o HHIt i d ƒ n Jd } n XLt | ‚ d  S(   Ni    i   s   * User Breaks   * Internal Errori   (   s   argvs   Nones   syss   oss   paths   splits   selfs   filenames   names   headers	   argumentss   option_dicts   optionss
   option_maps   preset_optionss   options   has_keys
   add_options   filess   startups   rcs
   SystemExits   parses   mains   KeyboardInterrupts   debugs	   tracebacks	   print_exc(   s   selfs   argvs   options   rc(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   __init__sP    # 	c    s0   NUV|  i i | ƒ W| |  i | i <d S(   s¨    Add a new Option instance to the Application dynamically.

            Note that this has to be done *before* .parse() is being
            executed.
        
        N(   s   selfs   optionss   appends   options
   option_maps   name(   s   selfs   option(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys
   add_optionNs   c    s   Y`at  Sd S(   s·    Set user defined instance variables.

            If this method returns anything other than None, the
            process is terminated with the return value as exit code.

        N(   s   None(   s   self(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   startupYs   c    s   cjkt  | ‚ d S(   sŸ    Exit the program.

            rc is used as exit code and passed back to the calling
            program. It defaults to 0 which usually means: OK.

        N(   s
   SystemExits   rc(   s   selfs   rc(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   exitcs   c    s,  mxzh  |  _ } {xV |  i D{]H } || i o }| i | | i | i <n d | | i | i <q# W€t |  i ƒ \ } } yÂ ‚t i |  i | | ƒ \ } } ƒ|  i oq „g  } …xU | D…]J } †t i | ƒ } ‡| o ˆ| i | ƒ n Š| | t | ƒ )qÑ W‹| } n Œ| |  _ | |  i |  _ Wn; Žt i j
 o) } |  i | ƒ t i d ƒ n X“|  i |  i ƒ } ”| t j	 o •t i | ƒ n ˜x#| D˜]\ } }	 ›y œt! i" |	 ƒ }	 Wn t# j
 o
 žn X¢d t! i$ | d d ƒ } £y ¤t& |  | ƒ }
 Wnp ¥t( j
 oa ¦|	 d j o= ¨| i) | ƒ o ©| | d | | <n «d | | <n ­|	 | | <n1 X¯|
 |	 ƒ } °| t j	 o ±t* | ‚ n qÐW´|  i+ |  i ƒ } µ| t j	 o ¶t i | ƒ n d S(   sx   Parse the command line and fill in self.values and self.files.

            After having parsed the options, the remaining command line
            arguments are interpreted as files and passed to .handle_files()
            for processing.

            As final step the option handlers are called in the order
            of the options given on the command line.

        i    i   s   handles   -s   _s    N(,   s   selfs   valuess   optionss   os   has_defaults   defaults   prefixs   names   _getopt_flagss   flagss   lflagss   getopts	   argumentss   optlists   filess   globbings   ls   fs   globs   gfs   appends   lens
   optionlists   errors   whys   helps   syss   exits   handle_filess   rcs   Nones
   optionnames   values   strings   atois
   ValueErrors   replaces   handlernames   getattrs   handlers   AttributeErrors   has_keys
   SystemExits   check_files(   s   selfs   filess   gfs   os
   optionnames   whys   optlists   fs   ls   values   handlers   valuess   handlernames   rcs   flagss   lflags(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   parsems`    	!	
 	
 c    s   ¸ÂÃt  Sd S(   sh   Apply some user defined checks on the files given in filelist.

            This may modify filelist in place. A typical application
            is checking that at least n files are given.
            
            If this method returns anything other than None, the
            process is terminated with the return value as exit code.
            
        N(   s   None(   s   selfs   filelist(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   check_files¸s   
c    s  ÅÇ|  i ƒ  È|  i og Éd GHËy Ì|  i |  i } Wn2 Ít t t f j
 o Î|  i |  i } n XÏd | GHn ÐHÑ|  i ƒ  Ò|  i	 o Ód GHÔd |  i	 GHÕHn Ö|  i
 o# ×t i |  i
 |  i ƒ GHØHn Ù| o  Úd d GHÛd G| GHÜHn d  S(   Ns	   Synopsis:s    s   Version:s    %ss   -iH   s   Note:(   s   selfs   print_headers   synopsiss   names	   NameErrors   KeyErrors	   TypeErrors   __dict__s   print_optionss   versions   abouts   strings   strips   note(   s   selfs   notes   synopsis(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   helpÅs*   
c    s/   Þàd d GHád G| GHâd d GHãHd  S(   Ns   -iH   s   Note:(   s   note(   s   selfs   note(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   noticeÞs   c    s5   åçd d GHè|  i |  i GHéd d GHêHd  S(   Ns   -iH   (   s   selfs   headers   __dict__(   s   self(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   print_headerås   c    s—   ìî|  i } ïd GHð| o ñd GHòd  Sn ót d „  | ƒ } ôt d „  | ƒ } õ| | } öx | Dö] } ÷d G| GHqv WøHd  S(   Ns   Options and default settings:s     Nonec    s   ó|  i d j S(   Ns   --(   s   xs   prefix(   s   x(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   <lambda>ós    c    s   ô|  i d j S(   Ns   -(   s   xs   prefix(   s   x(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   <lambda>ôs    s    (   s   selfs   optionss   filters   longs   shorts   itemss   o(   s   selfs   shorts   os   itemss   optionss   long(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   print_optionsìs   
 	c    s   t  Sd S(   s3    This may process the files list in place.
        N(   s   None(   s   selfs   files(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   handle_filess   c    s   	|  i ƒ  d Sd  S(   Ni    (   s   selfs   help(   s   selfs   arg(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   handle_h	s   c    s   d |  _ d S(   s!    Turn on verbose output.
        i   N(   s   selfs   verbose(   s   selfs   value(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   handle_vs   c    s   |  i ƒ  d Sd  S(   Ni    (   s   selfs   help(   s   selfs   arg(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   handle__helps   c    s   d |  _ d  S(   Ni   (   s   selfs   debug(   s   selfs   arg(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   handle__debugs   c    s:    |  i ƒ  !t i |  i |  i ƒ GH"H#d Sd  S(   Ni    (   s   selfs   print_headers   strings   strips	   copyrights   __dict__(   s   selfs   arg(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   handle__copyrights   c    sc   %'|  i ƒ  (|  i o/ )d GH*H+t i |  i |  i ƒ GH,Hn .d GH/H0d Sd  S(   Ns	   Examples:s   No examples available.i    (   s   selfs   print_headers   exampless   strings   strips   __dict__(   s   selfs   arg(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   handle__examples%s   c    s   2;<t  Sd S(   s3   Override this method as program entry point.

            The return value is passed to sys.exit() as argument.  If
            it is None, 0 is assumed (meaning OK). Unhandled
            exceptions are reported with exit status code 1 (see
            __init__ for further details).
            
        N(   s   None(   s   self(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   main2s   	(%   s   __name__s
   __module__s   __doc__s   optionss   SwitchOptions   preset_optionss   headers   names   synopsiss   versions   abouts   exampless	   copyrights   globbings   debugs   verboses   Nones   valuess   filess   __init__s
   add_options   startups   exits   parses   check_filess   helps   notices   print_headers   print_optionss   handle_filess   handle_hs   handle_vs   handle__helps   handle__debugs   handle__copyrights   handle__exampless   main(    (    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   ApplicationÃ sB   	Q													@

Kc     sf   ACd t  f d „  ƒ  Y} K| ƒ  }  L|  i d o M|  i ƒ  n Nd G|  i GHOd GHd  S(   Ns   MyApplicationc      s>   Ct  Z Dd Z Ee Z Fe d d ƒ g Z Hd „  Z RS(   Ns   Test Applications   -vs   verbosec    s   HId GHd  S(   Ns   VERBOSE, Yeah !(    (   s   selfs   arg(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   handle_vHs   (   s   __name__s
   __module__s   headers   __version__s   versions   Options   optionss   handle_v(    (    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   MyApplicationCs   			s   -hs   files:s   Bye...(   s   Applications   MyApplications   cmds   valuess   helps   files(   s   cmds   MyApplication(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   _testAs   s   __main__(   s   __doc__s   __version__s   syss   getopts   strings   globs   oss	   tracebacks   res   _getopt_flagss   invisible_inputs   option_dicts	   getpasswds   compiles
   _integerREs   _integerRangeREs   splits   sranges   paths
   expandvarss
   expandusers   joins   getcwds   abspaths   Options   ArgumentOptions   SwitchOptions   Applications   CommandLines   _tests   __name__(   s
   _integerREs   sranges   strings   invisible_inputs   abspaths   globs   SwitchOptions   _integerRangeREs   syss   Applications   _getopt_flagss   ArgumentOptions   __version__s   Options   option_dicts	   tracebacks   res   getopts   _tests	   getpasswds   oss   CommandLine(    (    s=   /mit/seven/lib/python2.2/site-packages/mx/Misc/CommandLine.pys   ? s&   	B
	-'ÿ }	