Files
intellecton/venv/lib/python3.12/site-packages/click/__pycache__/parser.cpython-312.pyc
T

150 lines
20 KiB
Plaintext
Raw Normal View History

Ë
jlJãó”dZddlmZddlmZddlZddlm Z ddl
m
Z ddl
m Z ddl
mZdd l
mZdd
lmZdd lmZdd lmZdd
lmZej*r$ddl
mZddl
mZddlmZddlmZddlmZddlmZej@d«Z! d!dZ"d"dZ#d#dZ$Gdd«Z%Gdd«Z&Gdd«Z'Gdd«Z(d$d „Z)y)%a;
This module started out as largely a copy paste from the stdlib's
optparse module with the features removed that we do not need from
optparse because we implement them in Click on a higher level (for
instance type handling, help formatting and a lot more).
The plan is to remove more and more from here over time.
The reason this is a different module and not optparse from the stdlib
is that there are differences in 2.x and 3.x about the error messages
generated and optparse in the stdlib uses gettext for no good reason
and might cause us issues.
Click uses parts of optparse written by Gregory P. Ward and maintained
by the Python Software Foundation. This is limited to code in parser.py.
Copyright 2001-2006 Gregory P. Ward. All rights reserved.
Copyright 2002-2006 Python Software Foundation. All rights reserved.
é)Ú annotationsN)Údeque)Úgettext)Úngettexté)ÚFLAG_NEEDS_VALUE©ÚUNSET)ÚBadArgumentUsage)ÚBadOptionUsage)Ú NoSuchOption)Ú
UsageError)ÚT_FLAG_NEEDS_VALUE)ÚT_UNSET)ÚArgument)ÚContext)ÚOption)Ú ParameterÚVcóZt|«}t|«}g}dŠdˆfd }|rʼn|j«}n|j«}|dk(r|j||««n|dkDrKt |«Dcgc]
}||«Œ }}|j «|jt
|««n2|dkr-‰ td«t|«Š|jt«|rŒÅ‰'t
|«|<g}t|dzd«|dzdt
|«t|«fScc}w)aGiven an iterable of arguments and an iterable of nargs specifications,
it returns a tuple with all the unpacked arguments at the first index
and all remaining arguments as the second.
The nargs specification is the number of arguments that should be consumed
or `-1` to indicate that this position should eat up all the remainders.
Missing items are filled with ``UNSET``.
Ncót |j«S|j«S#t$r tcYSwxYw©N)ÚpopleftÚpopÚ
IndexErrorr
)Úsposs €úO/home/antigravity/intellecton/venv/lib/python3.12/site-packages/click/parser.pyÚ_fetchz_unpack_args.<locals>._fetchDs8ø€ð ؈—y‘y“{Зu‘u“wøÜò ÜŠLð úsƒ%%¥77rrzCannot have two nargs < 0)rz
deque[str]Úreturnz
str | T_UNSET) rrrÚappendÚrangeÚreverseÚtupleÚ TypeErrorÚlenr
ÚreversedÚlist)ÚargsÚ
nargs_specÚrvrÚnargsÚxrs @rÚ _unpack_argsr/3s)ø€ô ;€DÜ"€JØ:<€BØ€Dõñ Ø ˆ×(‰Eà—N$ˆ AŠ:Ø I‰If˜T“lÕ
QŠYÜ<AÀ%»LÖ%I°q¡f¨T¥lÐ%IˆAÐ%IðÐØ— ‘ ” à I‰I”e˜A“hÕ Ø
QŠYØÐÜÐ ;Ór“7ˆ I‰I”eÔ ò- ð4 Ðܘ“;ˆˆ4‰ØˆÜ! " T¨A¡X Z 1ˆˆ4!‰8ˆ:ˆä ‹9”d˜4“jÐ Ð ùò-&JsÁ6D(cóf|dd}|j«rd|fS|dd|k(r
|dd|ddfS||ddfS)NrÚé)Úisalnum)ÚoptÚfirsts rÚ
_split_optr6osTØ ˆG€EØ ‡}}„Ø3ˆwˆØ
ˆ1ˆQ€xØ2Aˆw˜˜A˜B˜ÐÐØ #ab'ˆócóh| |j|St|«\}}||j|«Sr)Útoken_normalize_funcr6)r4ÚctxÚprefixs rÚ_normalize_optr<xs?Ø
€{c׈
ܘS“/K€FˆC؈X.¨sÓ 5r7cóLeZdZ d ddZedd«ZddZy) Ú_OptionNcóg|_g|_t«|_|D}t |«\}} |s$t t
d«j|¬««|jj|d«t|«dk(r*t| «dk(r|jj|«Œ|jj|«|jj|«ŒÄ|d}||_ ||_ ||_
||_||_y)Nz-Invalid start character for option ({option}))ÚoptionrrÚstore)Ú _short_optsÚ
_long_optsÚsetÚprefixesr6Ú
ValueErrorr-ÚformatÚaddr&r!ÚdestÚactionr,ÚconstÚobj)
ÚselfrLÚoptsrIrJr,rKr4r;Úvalues
rÚ__init__z_Option.__init__€ðˆÔ؈ŒÜ"%£%ˆŒ
àò
*ˆ& sO‰MˆFÜ ÜÐF×Nóóðð
M‰M× Ñ ˜f Q™iÔ 6‹{˜aÒ¤C¨£J°!¢OØ× Ñ ×Õ×& 
×! 
 ˆ>؈FàˆŒ ؈Œ ؈Œ
؈Œ
؈r7có|jdvS)N)rAr!)rJ)rMs rÚ takes_valuez_Option.takes_value¥sà{‰{Ð1r7có|jdk(r||j|j<n0|jdk(r$|j|j|j<ný|jdk(r6|jj |jg«j |«n¸|jdk(r@|jj |jg«j |j«ni|jdk(rA|jj
|jd«dz|j|j<ntd|jd «|jj |j«y)
NrAÚ store_constr!Ú append_constÚcountrrzunknown action 'ú')
rJrNrIrKÚ
setdefaultr!ÚgetrFÚorderrL)rMrOÚstates rÚprocessz_Option.process©s Ø ;‰;˜ !Ø$)ˆEJ‰Jt—y
[‰[˜
)Ø$(§J¡JˆEJ‰Jt—y
[‰[˜
J‰J× ! $§)¡)¨RÓ 0× 7¸Õ
[‰[˜
J‰J× ! $§)¡)¨RÓ 0× ¿
¹
Õ
[‰[˜
#Ø$)§J¡J§N¡N°4·9±9¸aÓ$@À1Ñ$DˆEJ‰Jt—y‘yÒ Ð· ± ¨}¸AÐ 
×ј4Ÿ8™8Õ$r7©NrN) rLÚ
CoreOptionrNúcabc.Sequence[str]rIú
str | NonerJr`r,ÚintrKú t.Any | None)r Úbool)rOzt.Anyr[Ú
_ParsingStater ÚNone)Ú__name__Ú
__module__Ú __qualname__rPÚpropertyrRr\©r7rr>r>sfð Ø#à
ð#ð#ðð #ð
ð #ð ð
#ðó#ðJòð
%r7r>có*eZdZdddZ ddZy)Ú _Argumentcó.||_||_||_yr)rIr,rL©rMrLrIr,s rrPz_Argument.__init__ºs؈Œ ؈Œ
؈r7có¶|jdkDrt|tj«sJt d|D««}|t |«k(rt }n>|dk7r9ttd«j|j|j¬««|dk(rt }||j|j<|jj|j«y)Nrc3ó,K|] }|tuŒy­wrr )Ú.0r.s rú <genexpr>z$_Argument.process.<locals>.<genexpr>Æsèø€Ò2 q˜œUœ
Ñ2ùsrz'Argument {name!r} takes {nargs} values.©Únamer,rj)r,Ú
isinstanceÚcabcÚSequenceÚsumr&r
r r-rGrIrNrZr!rL)rMrOr[Úholess rr\z_Argument.process¿ð
:‰:˜Š>ܘe¤T§]¡]Ô Ñ2¨EÔ2ˆEØœ˜E›
ÒØ˜!ÜÐ@×!ŸY™Y¨d¯j©jðHóóðð BŠ;܈Eà %ˆ
4—9Ø
×ј4Ÿ8™8Õ$r7r)rLÚ CoreArgumentrIr`r,ra)rOz,str | cabc.Sequence[str | T_UNSET] | T_UNSETr[rdr re)rfrgrhrPr\rjr7rrlrl¹s(ôð
ð
ô %r7rlcóeZdZddZy)rdcó<i|_g|_||_g|_yr)rNÚlargsÚrargsrZ)rMrs rrPz_ParsingState.__init__ÙsØ&(ˆŒ Ø "ˆŒ
؈Œ
Ø*,ˆ
r7N)rú list[str]r re)rfrgrhrPrjr7rrdrdØsô-r7rdcó®eZdZdZd
ddZ d ddZdddZ ddZddZddZ dd „Z
dd
Z dd Z dd Z
y)Ú
_OptionParserajThe option parser is an internal class that is ultimately used to
parse options and arguments. It's modelled after optparse and brings
a similar but vastly simplified API. It should generally not be used
directly as the high level Click classes wrap it for you.
It's not nearly as extensible as optparse or argparse as it does not
implement features that are implemented on a higher level (such as
types or defaults).
:param ctx: optionally the :class:`~click.Context` where this parser
should go with.
.. deprecated:: 8.2
Will be removed in Click 9.0.
Ncó²||_d|_d|_|"|j|_|j|_i|_i|_ddh|_g|_y)NTFú--)r:Úallow_interspersed_argsÚignore_unknown_optionsÚ
_short_optÚ _long_optÚ
_opt_prefixesÚ_args)rMr:s rrPz_OptionParser.__init__ñsaðˆŒð
.2ˆÔ
-2ˆÔ ˆ?Ø+.×+FÑ+Fˆ (Ø*-×*DÑ*Dˆ 'à.0ˆŒØ-/ˆŒØ! 4˜[ˆÔØ&(ˆ
r7có@|Dcgc]}t||j«Œ}}t||||||¬«}|jj |j
«|j D]}||j|<Œ|jD]}||j|<Œycc}w)azAdds a new option named `dest` to the parser. The destination
is not inferred (unlike with optparse) and needs to be explicitly
provided. Action can be any of ``store``, ``store_const``,
``append``, ``append_const`` or ``count``.
The `obj` can be used to identify the option in the order list
that is returned from the parser.
)rJr,rKN)
r<r:r>ÚupdaterErBrˆrCr‰) rMrLrNrIrJr,rKr4r@s rÚ
add_optionz_OptionParser.add_option s™ð":>Ö>°#”˜s D§H¡HÕ>ˆÐ˜˜d D°¸uÈEÔØ ×Ñ×! &§/¡/Ô× *ˆCØ#)ˆDO‰O˜ ð× )ˆCØ"(ˆDN‰N˜ ñ )ùò ?sBcóR|jjt|||¬««y)z±Adds a positional argument named `dest` to the parser.
The `obj` can be used to identify the option in the order list
that is returned from the parser.
)rIr,N)rr!rlrns rÚ add_argumentz_OptionParser.add_argument"sð
×Ñœ) C¨d¸Ar7cót|«} |j|«|j|«|j |j|jfS#t$r&|j|jj
sYŒQwxYw)aZParses positional arguments and returns ``(values, args, order)``
for the parsed options and arguments as well as the leftover