ž Ť˙fxEc@sKdZddlZddlZddlZddlZddlTdZejdeƒZejdeefƒZ e j ddƒZ Gd d „d ƒZ d d „Zd d„ejDƒZdd„Zdd„ZGdd„dƒZedkrGdZxKddddfD]7Zedeƒedjeeeƒƒƒeƒq WndS(u6distutils.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 iN(u*u[a-zA-Z](?:[a-zA-Z0-9-]*)u^%s$u ^(%s)=!(%s)$u-u_cBsÚ|EeZdZdZddd„Zdd„Zdd„Zdddd „Zd d „Z d d „Z dd„Z dd„Z dd„Z dd„Zdddd„Zdd„Zddd„Zdddd„ZdS(u FancyGetoptuŐ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 cCst||_i|_|jr(|jƒni|_i|_g|_g|_i|_i|_i|_ g|_ dS(N( u option_tableu option_indexu _build_indexualiasunegative_aliasu short_optsu long_optsu short2longu attr_nameu takes_argu option_order(uselfu option_table((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu__init__)s           uFancyGetopt.__init__cCs6|jjƒx"|jD]}||j|d= 2iu:invalid short option '%s': must a single character or Noneu=u:u>invalid negative alias '%s': aliased option '%s' takes a valueuginvalid alias '%s': inconsistent with aliased option '%s' (one of them takes a value, the other doesn'tuEinvalid long option name '%s' (must be letters, numbers, hyphens onlyNi˙˙˙˙i˙˙˙˙i˙˙˙˙(u long_optsu short_optsu short2longuclearurepeatu option_tableulenu ValueErroru isinstanceustruDistutilsGetoptErroruNoneuappendu takes_argunegative_aliasugetualiasu longopt_reumatchu get_attr_nameu attr_name(uselfuoptionulongushortuhelpurepeatualias_to((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu_grok_option_table…s^     "  !        uFancyGetopt._grok_option_tablec Cs>|dkr"tjdd…}n|dkr@tƒ}d }nd }|jƒdj|jƒ}y"t j |||j ƒ\}}Wn4t j k rş}zt |ƒ‚WYdd}~XnXxh|D]`\}}t |ƒdkr|ddkr|j|d}n>t |ƒdkr,|dd…dks2t‚|dd…}|jj|ƒ} | rc| }n|j|s¸|dksˆtd ƒ‚|jj|ƒ} | rŻ| }d}q¸d}n|j|} |rü|jj| ƒdk rüt|| dƒd}nt|| |ƒ|jj||fƒqÂW|r6||fS|SdS( uParse command-line options in args. Store as attributes on 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. iNu iiu-u--uuboolean option can't have valueTF(uNoneusysuargvu OptionDummyuTrueuFalseu_grok_option_tableujoinu short_optsugetoptu long_optsuerroruDistutilsArgErrorulenu short2longuAssertionErrorualiasugetu takes_argunegative_aliasu attr_nameurepeatugetattrusetattru option_orderuappend( uselfuargsuobjectucreated_objectu short_optsuoptsumsguoptuvalualiasuattr((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyugetoptŇsF     "".      uFancyGetopt.getoptcCs)|jdkrtdƒ‚n|jSdS(uŤReturns the list of (option, value) tuples processed by the previous run of 'getopt()'. Raises RuntimeError if 'getopt()' hasn't been called yet. u!'getopt()' hasn't been called yetN(u option_orderuNoneu RuntimeError(uself((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyuget_option_ordersuFancyGetopt.get_option_ordercCsđd}x||jD]q}|d}|d}t|ƒ}|ddkrS|d}n|d k rl|d}n||kr|}qqW|ddd}d}||} d|} |rĂ|g} n dg} x|jD]}|d d …\}}} t| | ƒ} |ddkr'|dd…}n|d krt| rZ| jd ||| dfƒqź| jd ||fƒnHd ||f}| rŤ| jd ||| dfƒn| jd|ƒx)| dd …D]}| j| |ƒqÍWqÖW| S(uŒGenerate help text (a list of strings, one per suggested line of output) from the option table for this FancyGetopt object. iiu=iiiNu uOption summary:Niu --%-*s %su --%-*s u%s (-%s)u --%-*si˙˙˙˙i˙˙˙˙i˙˙˙˙(u option_tableulenuNoneu wrap_textuappend(uselfuheaderumax_optuoptionulongushortulu opt_widthu line_widthu text_widthu big_indentulinesuhelputextu opt_names((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu generate_helpsF             ! uFancyGetopt.generate_helpcCsG|dkrtj}nx(|j|ƒD]}|j|dƒq(WdS(Nu (uNoneusysustdoutu generate_helpuwrite(uselfuheaderufileuline((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu print_helphs  uFancyGetopt.print_helpN(u__name__u __module__u __qualname__u__doc__uNoneu__init__u _build_indexuset_option_tableu add_optionu has_optionu get_attr_nameu_check_alias_dictu set_aliasesuset_negative_aliasesu_grok_option_tableugetoptuget_option_orderu generate_helpu print_help(u __locals__((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu FancyGetopts (       M= Ou FancyGetoptcCs)t|ƒ}|j|ƒ|j||ƒS(N(u FancyGetoptuset_negative_aliasesugetopt(uoptionsu negative_optuobjectuargsuparser((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu fancy_getoptos  u fancy_getoptcCsi|]}dt|ƒ“qS(u (uord(u.0u_wschar((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu us u cCs‚|dkrgSt|ƒ|kr)|gS|jƒ}|jtƒ}tjd|ƒ}dd„|Dƒ}g}x |r}g}d}xt|rút|dƒ}|||krŇ|j|dƒ|d=||}q‡|rö|d ddkrö|d =nPq‡W|rd|dkrC|j|dd|…ƒ|d|d…|d [string] Split 'text' into multiple lines of no more than 'width' characters each, and return the list of strings that results. u( +|-+)cSsg|]}|r|‘qS(((u.0uch((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu …s uwrap_text..iiu Nui˙˙˙˙i˙˙˙˙( uNoneulenu expandtabsu translateuWS_TRANSureusplituappendujoin(utextuwidthuchunksulinesucur_lineucur_lenul((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu wrap_textws:        u wrap_textcCs |jtƒS(uXConvert a long option name to a valid Python identifier by changing "-" to "_". (u translateu longopt_xlate(uopt((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyutranslate_longopt­sutranslate_longoptcBs)|EeZdZdZgdd„ZdS(u OptionDummyu_Dummy class just used as a place to hold command-line option values as instance attributes.cCs%x|D]}t||dƒqWdS(ukCreate a new OptionDummy instance. The attributes listed in 'options' will be initialized to None.N(usetattruNone(uselfuoptionsuopt((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu__init__¸s uOptionDummy.__init__N(u__name__u __module__u __qualname__u__doc__u__init__(u __locals__((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu OptionDummy´su OptionDummyu__main__u˘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 iii(u width: %du (u__doc__usysustringureugetoptudistutils.errorsu longopt_patucompileu longopt_reu neg_alias_reustru maketransu longopt_xlateu FancyGetoptu fancy_getoptu whitespaceuWS_TRANSu wrap_textutranslate_longoptu OptionDummyu__name__utextuwuprintujoin(((u;/opt/alt/python33/lib64/python3.3/distutils/fancy_getopt.pyu s($  ˙S  6