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

150 lines
20 KiB
Plaintext
Raw Normal View History

Ë
KÀjlJãó”—dZddlmZddlmZddlZddlm Z ddl
m
Z ddl
m Z ddl
mZdd l
mZdd
lmZdd lmZdd lmZdd
lmZej*r$ddl
mZddl
mZddlmZddlmZddlmZddlmZej@d«Z! d!d„Z"d"d„Z#d#d„Z$Gd„d«Z%Gd„d«Z&Gd„d«Z'Gd„d«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óZ‡—t|«}t|«}g}dŠdˆfd„ }|rʼn€|j«}n|j«}|dk(r|j||««n‚|dkDrKt |«D�cgc]
}||«‘Œ }}‰�|j «|jt
|««n2|dkr-‰� td«‚t|«Š|jt«|rŒÅ‰�'t
|«|‰<g}t|‰dzd«|‰dzdt
|«t|«fScc}w)a�Given 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
)ÚcÚ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Ü�zÓ"€JØ:<€BØ€Dõñ Ø ˆ<Ø×&Ñ&Ó(‰Eà—N‘NÓ$ˆEà �AŠ:Ø �I‰I‘f˜T“lÕ #Ø
�QŠYÜ<AÀ%»LÖ%I°q¡f¨T¥lÐ%IˆAÐ%IðÐØ— ‘ ” à �I‰I”e˜A“hÕ Ø
�QŠYØÐÜÐ ;Ó<Ð<ä�r“7ˆDØ �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�5ÒØ�2�Aˆw˜˜A˜B˜ÐÐØ �#�a�b�'ˆ>Ðócóh—|� |j€|St|«\}}|›|j|«›�Sr)Útoken_normalize_funcr6)r4ÚctxÚprefixs rÚ_normalize_optr<xs?€Ø
€{�c×.Ñ.Ð6؈
ܘS“/�K€FˆC؈X�c×.Ñ.¨sÓ3Ð4Ð 5Ð5r7cóL—eZdZ d dd„Zedd„«Zdd„Zy) Ú_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__€sú€ðˆÔ؈ŒÜ"%£%ˆŒ
àò
*ˆCÜ& s›O‰MˆF�EÙÜ ÜÐEÓF×MÑMØ"ðNóóðð
�M‰M× Ñ ˜f Q™iÔ (Ü�6‹{˜aÒ¤C¨£J°!¢OØ× Ñ ×'Ñ'¨Õ,à—‘×&Ñ& sÔ+Ø—
‘
×!Ñ! &Õ)ð
*ð ˆ>؈FàˆŒ ؈Œ ؈Œ
؈Œ
؈�r7có—|jdvS)N)rAr!)rJ)rMs rÚ takes_valuez_Option.takes_value¥s€à�{‰{Ð1Ð1Ð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|j›d �«‚|jj |j«y)
NrAÚ store_constr!Ú append_constÚcountrrzunknown action 'ú')
rJrNrIrKÚ
setdefaultr!ÚgetrFÚorderrL)rMrOÚstates rÚprocessz_Option.process©s €Ø �;‰;˜'Ò !Ø$)ˆE�J‰J�t—y‘yÓ !Ø
�[‰[˜MÒ
)Ø$(§J¡JˆE�J‰J�t—y‘yÒ !Ø
�[‰[˜HÒ
$Ø �J‰J× !Ñ ! $§)¡)¨RÓ 0× 7Ñ 7¸Õ >Ø
�[‰[˜NÒ
*Ø �J‰J× !Ñ ! $§)¡)¨RÓ 0× 7Ñ 7¸¿
¹
Õ CØ
�[‰[˜GÒ
#Ø$)§J¡J§N¡N°4·9±9¸aÓ$@À1Ñ$DˆE�J‰J�t—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ò2óð2ô
%r7r>có*—eZdZddd„Z dd„Zy)Ú _Argumentcó.—||_||_||_yr)rIr,rL©rMrLrIr,s rrPz_Argument.__init__ºs€ØˆŒ ؈Œ
؈�r7có¶—|jdkDr�t|tj«sJ‚t 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ùs‚rz'Argument {name!r} takes {nargs} values.©Únamer,rj)r,Ú
isinstanceÚcabcÚSequenceÚsumr&r
r r-rGrIrNrZr!rL)rMrOr[Úholess rr\z_Argument.process¿sµ€ð
�:‰:˜Š>ܘe¤T§]¡]Ô3Ð 3Ð3ÜÑ2¨EÔ2Ó2ˆEØœ˜E›
Ò"ؘܑ!’Ü&ÜÐ?Ó@×GÑGØ!ŸY™Y¨d¯j©jðHóóðð �BŠ;܈Eà %ˆ�
‰
�4—9‘9ÑØ
� ‰ ×ј4Ÿ8™8Õ$r7N©r)rLÚ CoreArgumentrIr`r,ra)rOz,str | cabc.Sequence[str | T_UNSET] | T_UNSETr[rdr re)rfrgrhrPr\rjr7rrlrl¹s(„ôð
%à;ð%ðð%ð
ô %r7rlcó—eZdZdd„Zy)rdcó<—i|_g|_||_g|_yr)rNÚlargsÚrargsrZ)rMrs rrPz_ParsingState.__init__Ùs€Ø&(ˆŒ Ø "ˆŒ
؈Œ
Ø*,ˆ�
r7N)rú list[str]r re)rfrgrhrPrjr7rrdrdØs„ô-r7rdcó®—eZdZdZd
dd„Z d dd„Zddd„Z dd„Zdd„Zdd„Z 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Ñ*DˆDÔ 'à.0ˆŒØ-/ˆŒØ! 4˜[ˆÔØ&(ˆ�
r7có@—|D�cgc]}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>rŠÚupdaterErBrˆrCr‰) rMrLrNrIrJr,rKr4r@s rÚ
add_optionz_OptionParser.add_option s™€ð":>Ö>°#”˜s D§H¡HÕ-Ð>ˆÐ>ܘ˜d D°¸uÈEÔRˆØ ×Ñ×!Ñ! &§/¡/Ô2Ø×%Ñ%ò *ˆCØ#)ˆD�O‰O˜CÒ ð *à×$Ñ$ò )ˆCØ"(ˆD�N‰N˜3Ò ñ )ùò ?s…Bcó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)r‹r!rlrns rÚ add_argumentz_OptionParser.add_argument"s€ð
�
‰
×Ñœ) C¨d¸%Ô@ÕAr7có—t|«} |j|«|j|«|j |j|jfS#t$r&|j�|jj
s‚YŒQwxYw)aZParses positional arguments and returns ``(values, args, order)``
for the parsed options and arguments as well as the leftover