ó Û@ŸSc@sÅdZdZddlZddlZddlZddlmZddlmZddlm Z m Z m Z mZmZmZmZmZmZmZyddlmZeZWnek rÉeZnXddlmZd „Zd „Zd „Zd „Z d „Z!d„Z"d„Z#d„Z$d„Z%d„Z&ddl'Z'de fd„ƒYZ de fd„ƒYZ de _(d„Z)d„Z*e*e_*defd„ƒYZ+dej,dd„Z-d!Z.dS("sAdd an abstraction level to transparently import optik classes from optparse (python >= 2.3) or the optik package. It also defines three new types for optik/optparse command line parser : * regexp argument of this type will be converted using re.compile * csv argument of this type will be converted using split(',') * yn argument of this type will be true if 'y' or 'yes', false if 'n' or 'no' * named argument of this type are in the form = or : * password argument of this type wont be converted but this is used by other tools such as interactive prompt for configuration to double check value and use an invisible field * multiple_choice same as default "choice" type but multiple choices allowed * file argument of this type wont be converted but checked that the given file exists * color argument of this type wont be converted but checked its either a named color or a color specified using hexadecimal notation (preceded by a #) * time argument of this type will be converted to a float value in seconds according to time units (ms, s, min, h, d) * bytes argument of this type will be converted to a float value in bytes according to byte units (b, kb, mb, gb, tb) srestructuredtext eniÿÿÿÿN(tcopy(texists( t OptionParsertOptiont OptionGrouptOptionContainertOptionValueErrort OptionErrortValuest HelpFormattert NO_DEFAULTt SUPPRESS_HELP(tDateTime(t splitstripcCsRt|dƒr|Sytj|ƒSWn'tk rMtd||fƒ‚nXdS(sPcheck a regexp value by trying to compile it return the compiled regexp tpatterns#option %s: invalid regexp value: %rN(thasattrtretcompilet ValueErrorR(toptiontopttvalue((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyt check_regexpFs cCsUt|ttfƒr|Syt|ƒSWn'tk rPtd||fƒ‚nXdS(sTcheck a csv value by trying to split it return the list of separated values s option %s: invalid csv value: %rN(t isinstancetlistttupleR RR(RRR((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyt check_csvRs cCsYt|tƒrt|ƒS|dkr)tS|dkr9tSd}t|||fƒ‚dS( s>check a yn value return true for yes and false for no tytyestntnos<option %s: invalid yn value %r, should be in (y, yes, n, no)N(Rsyes(Rsno(RtinttbooltTruetFalseR(RRRtmsg((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pytcheck_yn^s   cCsÈt|tƒr|Sg}x|t|||ƒD]h}|jdƒdkrc|j|jddƒƒq,|jdƒdkr,|j|jddƒƒq,q,W|r¨t|ƒSd}t|||fƒ‚dS(sVcheck a named value return a dictionary containing (name, value) associations t=iÿÿÿÿit:sMoption %s: invalid named value %r, should be = or :N(RtdictRtfindtappendtsplitR(RRRtvaluesR#((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyt check_namedks  cCs|S(s,check a password value (can't be empty) ((RRR((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pytcheck_password}scCs0t|ƒr|Sd}t|||fƒ‚dS(s/check a file value return the filepath s!option %s: file %r does not existN(RR(RRRR#((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyt check_fileƒs cCs?ytj|dƒSWn$tjk r:td|ƒ‚nXdS(s/check a file value return the filepath s%Y/%m/%ds#expected format of %s is yyyy/mm/ddN(R tstrptimetErrorR(RRR((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyt check_dates cCsXtjd|tjƒr|Stjd|tjƒr8|Sd}t|||fƒ‚dS(s†check a color value and returns it /!\ does *not* check color labels (like 'red', 'green'), only checks hexadecimal forms s [a-z0-9 ]+$s #[a-f0-9]{6}sYoption %s: invalid color : %r, should be either hexadecimal value or predefined colorN(RtmatchtIR(RRRR#((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyt check_color—s cCs?ddlm}m}t|tttfƒr2|S|||ƒS(Niÿÿÿÿ(t TIME_UNITSt apply_units(tlogilab.common.textutilsR5R6RRtlongtfloat(RRRR5R6((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyt check_time§scCs6ddlm}m}t|dƒr)|S|||ƒS(Niÿÿÿÿ(t BYTE_UNITSR6t__int__(R7R;R6R(RRRR;R6((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyt check_bytes­sRc BsæeZdZejdZejd d gZeejƒZeed ] ((RNRŸ((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyR›RscCs|djg|jƒD]}|jƒ^qƒ}|jddƒ}|jƒj|ƒrh|t|ƒ}nd||jƒfS(Ns s . s s.SH DESCRIPTION .B %s %s (R~Rtlstriptreplacetlowert startswithtlenR‘(RNRŸR•tline((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyR™\s  %cCsUdt|d|jƒ|j|j|jf}t|dƒrQ|d|j7}n|S(Ns}.SH SEE ALSO /usr/share/doc/pythonX.Y-%s/ .SH BUGS Please report bugs on the project's mailing list: %s .SH AUTHOR %s <%s> t debian_namet copyrights .SH COPYRIGHT %s (R\tmodnamet mailinglisttauthort author_emailRR¬(RNRttail((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyt format_tailgs ( RdReRfRLRuRŠR‚R¡RšR˜R›R™R²(((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyRƒs        icCs^tƒ}||_||_||j|||ƒIJ||j|ƒIJ||j|ƒIJdS(s(generate a man page from an optik parserN(RƒRpRaR¡RxR²(RœRRžtstreamRIRs((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pytgenerate_manpage|s    RRR(RRs OptionGroupsOptionValueErrorsValues(/Rft __docformat__RtsysRFRtos.pathRtoptparseRRmRRKRRRRRR R R tmxR R!Rjt ImportErrorR"R7R RRR$R,R-R.R1R4R:R=RVRIR{RxRƒtstdoutR´t__all__(((sR/Users/jacob/code/ruby/exercism-analysis/vendor/python/logilab/common/optik_ext.pyt0sD   F         ;    a