ž ¬ÿf@c@s dZddddgZddlZyddlmZWnek rXdd „ZYnXGd d„deƒZeZgd d„Z gd d„Z d d„Z dd„Z dd„Z dd„ZedkrddlZee ejdd…dddgƒƒndS(uŠParser for command line options. This module helps scripts to parse the command line arguments in sys.argv. It supports the same conventions as the Unix getopt() function (including the special meanings of arguments of the form `-' and `--'). Long options similar to those supported by GNU software may be used as well via an optional third argument. This module provides two functions and an exception: getopt() -- Parse command line options gnu_getopt() -- Like getopt(), but allow option and non-option arguments to be intermixed. GetoptError -- exception (class) raised with 'opt' attribute, which is the option involved with the exception. u GetoptErroruerrorugetoptu gnu_getoptiN(ugettextcCs|S(N((us((u+/opt/alt/python33/lib64/python3.3/getopt.pyu_)su_cBs;|EeZdZdZdZddd„Zdd„ZdS(u GetoptErrorucCs)||_||_tj|||ƒdS(N(umsguoptu Exceptionu__init__(uselfumsguopt((u+/opt/alt/python33/lib64/python3.3/getopt.pyu__init__.s  uGetoptError.__init__cCs|jS(N(umsg(uself((u+/opt/alt/python33/lib64/python3.3/getopt.pyu__str__3suGetoptError.__str__N(u__name__u __module__u __qualname__uoptumsgu__init__u__str__(u __locals__((u+/opt/alt/python33/lib64/python3.3/getopt.pyu GetoptError+sc Csg}t|ƒtdƒkr*|g}n t|ƒ}xÍ|r|djdƒr|ddkr|ddkr†|dd…}Pn|djdƒrÏt||ddd…||dd…ƒ\}}q9t||ddd…||dd…ƒ\}}q9W||fS(u@getopt(args, options[, long_options]) -> opts, args Parses command line options and parameter list. args is the argument list to be parsed, without the leading reference to the running program. Typically, this means "sys.argv[1:]". shortopts is the string of option letters that the script wants to recognize, with options that require an argument followed by a colon (i.e., the same format that Unix getopt() uses). If specified, longopts is a list of strings with the names of the long options which should be supported. The leading '--' characters should not be included in the option name. Options which require an argument should be followed by an equal sign ('='). The return value consists of two elements: the first is a list of (option, value) pairs; the second is the list of program arguments left after the option list was stripped (this is a trailing slice of the first argument). Each option-and-value pair returned has the option as its first element, prefixed with a hyphen (e.g., '-x'), and the option argument as its second element, or an empty string if the option has no argument. The options occur in the list in the same order in which they were found, thus allowing multiple occurrences. Long and short options may be mixed. uiu-u--iNi(utypeulistu startswithudo_longsu do_shorts(uargsu shortoptsulongoptsuopts((u+/opt/alt/python33/lib64/python3.3/getopt.pyugetopt8s  ,67cCs g}g}t|tƒr'|g}n t|ƒ}|jdƒr[|dd…}d }n!tjjdƒrvd }nd }x|r•|ddkr­||dd…7}Pn|ddd…dkrýt ||ddd…||dd…ƒ\}}q|ddd…dkr]|ddkr]t ||ddd…||dd…ƒ\}}q|rq||7}Pq|j |dƒ|dd…}qW||fS( ugetopt(args, options[, long_options]) -> opts, args This function works like getopt(), except that GNU style scanning mode is used by default. This means that option and non-option arguments may be intermixed. The getopt() function stops processing options as soon as a non-option argument is encountered. If the first character of the option string is `+', or if the environment variable POSIXLY_CORRECT is set, then option processing stops as soon as a non-option argument is encountered. u+iNuPOSIXLY_CORRECTiu--iu-TF( u isinstanceustrulistu startswithuTrueuosuenvironugetuFalseudo_longsu do_shortsuappend(uargsu shortoptsulongoptsuoptsu prog_argsuall_options_first((u+/opt/alt/python33/lib64/python3.3/getopt.pyu gnu_getoptcs2     6*6 c Cs y|jdƒ}Wntk r-d}Yn&X|d|…||dd…}}t||ƒ\}}|r½|dkrå|sœttdƒ||ƒ‚n|d|dd…}}qån(|dk råttdƒ||ƒ‚n|jd||pûdfƒ||fS(Nu=iuoption --%s requires argumentiu%option --%s must not have an argumentu--u(uindexu ValueErroruNoneu long_has_argsu GetoptErroru_uappend(uoptsuoptulongoptsuargsuiuoptarguhas_arg((u+/opt/alt/python33/lib64/python3.3/getopt.pyudo_longs•s  % ! udo_longscsÕ‡fdd†|Dƒ}|s;ttdƒˆˆƒ‚nˆ|krQdˆfSˆd|krkd ˆfSt|ƒdkr™ttdƒˆˆƒ‚n|d}|jdƒ}|rË|dd …}n||fS( Ncs%g|]}|jˆƒr|‘qS((u startswith(u.0uo(uopt(u+/opt/alt/python33/lib64/python3.3/getopt.pyu ¬s u!long_has_args..uoption --%s not recognizedu=iuoption --%s not a unique prefixiFTiÿÿÿÿ(u GetoptErroru_uFalseuTrueulenuendswith(uoptulongoptsu possibilitiesu unique_matchuhas_arg((uoptu+/opt/alt/python33/lib64/python3.3/getopt.pyu long_has_args«s    u long_has_argscCsÀx³|dkrµ|d|dd…}}t||ƒr•|dkr…|sgttdƒ||ƒ‚n|d|dd…}}n|d}}nd}|jd||fƒqW||fS(Nuiiuoption -%s requires argumentu-(u short_has_argu GetoptErroru_uappend(uoptsu optstringu shortoptsuargsuoptuoptarg((u+/opt/alt/python33/lib64/python3.3/getopt.pyu do_shortsÀs  u do_shortscCsnxNtt|ƒƒD]:}|||ko4dknr|jd|dƒSqWttdƒ||ƒ‚dS(Nu:iuoption -%s not recognized(urangeulenu startswithu GetoptErroru_(uoptu shortoptsui((u+/opt/alt/python33/lib64/python3.3/getopt.pyu short_has_argÏs u short_has_argu__main__iua:bualpha=ubeta(u__doc__u__all__uosugettextu_u ImportErroru Exceptionu GetoptErroruerrorugetoptu gnu_getoptudo_longsu long_has_argsu do_shortsu short_has_argu__name__usysuprintuargv(((u+/opt/alt/python33/lib64/python3.3/getopt.pyus"   +2