ó œÃÒYc@sìddlZddlZddlmZmZmZmZmZmZm Z ddl m Z ddl m Z mZdefd„ƒYZdefd „ƒYZd efd „ƒYZd efd „ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZd efd!„ƒYZdd"„ZeƒZ eƒZ!eƒZ"eƒZ#eƒZ$eƒZ%dS(#iÿÿÿÿNi(t open_streamt text_typetfilename_to_uitget_filesystem_encodingt get_streerrort_get_argv_encodingtPY2(t BadParameter(tsafecalltLazyFilet ParamTypecBsbeZdZeZdZdZddd„Zd„Z d„Z d„Z d„Z ddd„Z RS(sÒHelper for converting values through types. The following is necessary for a valid type: * it needs a name * it needs to pass through None unchanged * it needs to convert from a string * it needs to convert its result type through unchanged (eg: needs to be idempotent) * it needs to be able to deal with param and context being `None`. This can be the case when the object is used with prompt inputs. cCs#|dk r|j|||ƒSdS(N(tNonetconvert(tselftvaluetparamtctx((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyt__call__$s cCsdS(s>Returns the metavar default for this param if it provides one.N((R R((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyt get_metavar(scCsdS(stOptionally might return extra information about a missing parameter. .. versionadded:: 2.0 N((R R((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pytget_missing_message+scCs|S(siConverts the value. This is not invoked for values that are `None` (the missing value). ((R RRR((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR 2scCs|p dj|jƒS(suGiven a value from an environment variable this splits it up into small chunks depending on the defined envvar list splitter. If the splitter is set to `None`, which means that whitespace splits, then leading and trailing whitespace is ignored. Otherwise, leading and trailing splitters usually lead to empty items being included. t(tsplittenvvar_list_splitter(R trv((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pytsplit_envvar_value8scCst|d|d|ƒ‚dS(s4Helper method to fail with an invalid value message.RRN(R(R tmessageRR((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pytfailBsN(t__name__t __module__t__doc__tFalset is_compositeR tnameRRRRR RR(((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR s     tCompositeParamTypecBseZeZed„ƒZRS(cCs tƒ‚dS(N(tNotImplementedError(R ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pytarityJs(RRtTrueRtpropertyR#(((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR!Gst FuncParamTypecBseZd„Zd„ZRS(cCs|j|_||_dS(N(RR tfunc(R R'((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyt__init__Qs cCsxy|j|ƒSWn`tk rsyt|ƒ}Wn)tk r\t|ƒjddƒ}nX|j|||ƒnXdS(Nsutf-8treplace(R't ValueErrorRt UnicodeErrortstrtdecodeR(R RRR((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR Us  (RRR(R (((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR&Os tUnprocessedParamTypecBs eZdZd„Zd„ZRS(ttextcCs|S(N((R RRR((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR cscCsdS(Nt UNPROCESSED((R ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyt__repr__fs(RRR R R1(((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR.`s tStringParamTypecBs eZdZd„Zd„ZRS(R/cCs˜t|tƒr”tƒ}y|j|ƒ}Wnbtk rtƒ}||kry|j|ƒ}WqŒtk rˆ|jddƒ}qŒXqnX|S|S(Nsutf-8R)(t isinstancetbytesRR-R+R(R RRRtenctfs_enc((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR ms     cCsdS(NtSTRING((R ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR1|s(RRR R R1(((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR2js tChoicecBsAeZdZdZd„Zd„Zd„Zd„Zd„ZRS(s³The choice type allows a value to be checked against a fixed set of supported values. All of these values have to be strings. See :ref:`choice-opts` for an example. tchoicecCs ||_dS(N(tchoices(R R:((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR(ˆscCsddj|jƒS(Ns[%s]t|(tjoinR:(R R((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR‹scCsddj|jƒS(NsChoose from %s.s, (R<R:(R R((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyRŽscCsš||jkr|S|dk rm|jdk rm|j|ƒ}x-|jD]}|j|ƒ|krG|SqGWn|jd|dj|jƒf||ƒdS(Ns$invalid choice: %s. (choose from %s)s, (R:R ttoken_normalize_funcRR<(R RRRR9((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR ‘s   cCsdt|jƒS(Ns Choice(%r)(tlistR:(R ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR1¡s( RRRR R(RRR R1(((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR8€s    t IntParamTypecBs eZdZd„Zd„ZRS(tintegercCsCyt|ƒSWn.ttfk r>|jd|||ƒnXdS(Ns%s is not a valid integer(tintR*R+R(R RRR((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR ¨scCsdS(NtINT((R ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR1®s(RRR R R1(((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR?¥s tIntRangecBs8eZdZdZdded„Zd„Zd„ZRS(sA parameter that works similar to :data:`click.INT` but restricts the value to fit into a range. The default behavior is to fail if the value falls outside the range, but it can also be silently clamped between the two edges. See :ref:`ranges` for an example. s integer rangecCs||_||_||_dS(N(tmintmaxtclamp(R RDRERF((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR(¼s  cCs;tj||||ƒ}|jrn|jdk rF||jkrF|jS|jdk rn||jkrn|jSn|jdk rŒ||jksª|jdk r7||jkr7|jdkrÜ|jd||jf||ƒq7|jdkr|jd||jf||ƒq7|jd||j|jf||ƒn|S(Ns-%s is bigger than the maximum valid value %s.s.%s is smaller than the minimum valid value %s.s)%s is not in the valid range of %s to %s.(R?R RFRDR RER(R RRRR((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR Ás"      cCsd|j|jfS(NsIntRange(%r, %r)(RDRE(R ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR1ÕsN( RRRR R RR(R R1(((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyRC²s  t BoolParamTypecBs eZdZd„Zd„ZRS(tbooleancCs`t|tƒrt|ƒS|jƒ}|d kr5tS|d krEtS|jd |||ƒdS( Nttruet1tyestytfalset0tnotns%s is not a valid boolean(strueRJsyesRL(sfalseRNsnoRP(R3tbooltlowerR$RR(R RRR((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR Üs    cCsdS(NtBOOL((R ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR1æs(RRR R R1(((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyRGÙs tFloatParamTypecBs eZdZd„Zd„ZRS(tfloatcCsCyt|ƒSWn.ttfk r>|jd|||ƒnXdS(Ns&%s is not a valid floating point value(RUR+R*R(R RRR((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR ís  cCsdS(NtFLOAT((R ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR1ôs(RRR R R1(((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyRTês tUUIDParameterTypecBs eZdZd„Zd„ZRS(tuuidcCsyddl}y8tr6t|tƒr6|jdƒ}n|j|ƒSWn.ttfk rt|jd|||ƒnXdS(Niÿÿÿÿtasciis%s is not a valid UUID value( RXRR3RtencodetUUIDR+R*R(R RRRRX((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR ûs cCsdS(NR[((R ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR1s(RRR R R1(((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyRWøs tFilecBsJeZdZdZejjZdddde d„Z d„Z d„Z RS(sDeclares a parameter to be a file for reading or writing. The file is automatically closed once the context tears down (after the command finished working). Files can be opened for reading or writing. The special value ``-`` indicates stdin or stdout depending on the mode. By default, the file is opened for reading text data, but it can also be opened in binary mode or for writing. The encoding parameter can be used to force a specific encoding. The `lazy` flag controls if the file should be opened immediately or upon first IO. The default is to be non lazy for standard input and output streams as well as files opened for reading, lazy otherwise. Starting with Click 2.0, files can also be opened atomically in which case all writes go into a separate file in the same folder and upon completion the file will be moved over to the original location. This is useful if a file regularly read by other users is modified. See :ref:`file-args` for more information. tfilenametrtstrictcCs1||_||_||_||_||_dS(N(tmodetencodingterrorstlazytatomic(R R`RaRbRcRd((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR("s     cCs=|jdk r|jS|dkr&tSd|jkr9tStS(Nt-tw(RcR RR`R$(R R((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pytresolve_lazy_flag*s cCsCyút|dƒs!t|dƒr%|S|j|ƒ}|r„t||j|j|jd|jƒ}|dk r€|j|j ƒn|St ||j|j|jd|jƒ\}}|dk rõ|rÜ|jt |j ƒƒqõ|jt |j ƒƒn|SWnBttfk r>}|jdt|ƒt|ƒf||ƒnXdS(NtreadtwriteRdsCould not open file: %s: %s(thasattrRgR R`RaRbRdR t call_on_closetclose_intelligentlyRRtclosetflushtIOErrortOSErrorRRR(R RRRRctft should_closete((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR 3s.       N( RRRR tostpathtpathsepRR RR(RgR (((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR\s    tPathc BsMeZdZejjZeeeeeeedd„Z d„Z d„Z RS(såThe path type is similar to the :class:`File` type but it performs different checks. First of all, instead of returning an open file handle it returns just the filename. Secondly, it can perform various basic checks about what the file or directory should be. .. versionchanged:: 6.0 `allow_dash` was added. :param exists: if set to true, the file or directory needs to exist for this value to be valid. If this is not required and a file does indeed not exist, then all further checks are silently skipped. :param file_okay: controls if a file is a possible value. :param dir_okay: controls if a directory is a possible value. :param writable: if true, a writable check is performed. :param readable: if true, a readable check is performed. :param resolve_path: if this is true, then the path is fully resolved before the value is passed onwards. This means that it's absolute and symlinks are resolved. :param allow_dash: If this is set to `True`, a single dash to indicate standard streams is permitted. :param type: optionally a string type that should be used to represent the path. The default is `None` which means the return value will be either bytes or unicode depending on what makes most sense given the input data Click deals with. c Cs®||_||_||_||_||_||_||_||_|jrp|j rpd|_d|_ n|jr˜|j r˜d|_d|_ nd|_d|_ dS(NtfileR\t directoryt DirectoryRuRw( texistst file_okaytdir_okaytwritabletreadablet resolve_patht allow_dashttypeR t path_type( R R{R|R}R~RR€RRƒ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR(ts              cCs_|jdk r[t||jƒ r[|jtkrF|jtƒƒ}q[|jtƒƒ}n|S(N(R‚R R3RR-RRZ(R R((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pytcoerce_path_resultŠs "cCsÕ|}|jo!|jo!|dk}|sÈ|jrHtjj|ƒ}nytj|ƒ}WnMtk rª|js|j |ƒS|j d|j t |ƒf||ƒnX|j rðtj |jƒrð|j d|j t |ƒf||ƒn|j r5tj|jƒr5|j d|j t |ƒf||ƒn|jr}tj|tjƒ r}|j d|j t |ƒf||ƒn|jrÈtj|tjƒ rÈ|j d|j t |ƒf||ƒqÈn|j |ƒS(NRes%s "%s" does not exist.s%s "%s" is a file.s%s "%s" is a directory.s%s "%s" is not writable.s%s "%s" is not readable.(ReRe(R|RR€RtRutrealpathtstatRpR{R„RRƒRtS_ISREGtst_modeR}tS_ISDIRR~taccesstW_OKRtR_OK(R RRRRtis_dashtst((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR ’sF                 N( RRRRtRuRvRRR$R R(R„R (((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyRwVs    tTuplecBs>eZdZd„Zed„ƒZed„ƒZd„ZRS(sThe default behavior of Click is to apply a type on a value directly. This works well in most cases, except for when `nargs` is set to a fixed count and different types should be used for different items. In this case the :class:`Tuple` type can be used. This type can only be used if `nargs` is set to a fixed number. For more information see :ref:`tuple-type`. This can be selected by using a Python tuple literal as a type. :param types: a list of types that should be used for the tuple items. cCs&g|D]}t|ƒ^q|_dS(N(t convert_typettypes(R R‘tty((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR(ËscCs"ddjd„|jDƒƒdS(NtÐst>(R<R‘(R ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR ÎscCs t|jƒS(N(tlenR‘(R ((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR#ÒscsSt|ƒt|jƒkr*tdƒ‚nt‡‡fd†t|j|ƒDƒƒS(NsLIt would appear that nargs is set to conflict with the composite type arity.c3s'|]\}}||ˆˆƒVqdS(N((R•R’tx(RR(s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pys Ús(R—R‘t TypeErrorttupletzip(R RRR((RRs^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR Ös(RRRR(R%R R#R (((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyR½s   cCs3t}|dkrZ|dk rZt|tƒrEttt|ƒƒ}n t|ƒ}t}nt|tƒrst|ƒSt|tƒr†|S|t ksª|t ksª|dkr®t S|t kr¾t S|tkrÕ| rÕtS|tkråtS|rït Sy&t|tƒrtd|ƒ‚nWntk r(nXt|ƒS(sMConverts a callable or python ty into the most appropriate param ty. s7Attempted to use an uninstantiated parameter type (%s).N(RR R3RštmapR‚R$RR RR,R7RARBRQRSRURVt issubclasstAssertionErrorR™R&(R’tdefaultt guessed_type((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyRÝs6   $   (&RtR†t_compatRRRRRRRt exceptionsRtutilsRR tobjectR R!R&R.R2R8R?RCRGRTRWR\RwRR RR0R7RBRVRSR[(((s^/private/var/folders/w6/vb91730s7bb1k90y_rnhql1dhvdd44/T/pip-build-w4MwvS/click/click/types.pyts2  4= % 'Ng 6