Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
parser.cpython-313.pyc148 linesDownload Raw Back to __pycache__
1�

2�jBJ���SrSSKJr SSKJr SSKrSSKJ	r	 SSK3J4r SSK5Jr SSK
Jr SS	K
Jr SS6KJr SSKJr SSKJr SS
KJr \R*(a$SSK
Jr SSK
Jr SSKJr SSKJr SSKJr SSKJr \R@"S5r!S!Sjr"S"Sjr#S#Sjr$"SS5r%"SS5r&"SS5r'"SS5r(S$S jr)g)%a;7This module started out as largely a copy paste from the stdlib's8optparse module with the features removed that we do not need from9optparse because we implement them in Click on a higher level (for10instance type handling, help formatting and a lot more).11 12The plan is to remove more and more from here over time.13 14The reason this is a different module and not optparse from the stdlib15is that there are differences in 2.x and 3.x about the error messages16generated and optparse in the stdlib uses gettext for no good reason17and might cause us issues.18 19Click uses parts of optparse written by Gregory P. Ward and maintained20by the Python Software Foundation. This is limited to code in parser.py.21 22Copyright 2001-2006 Gregory P. Ward. All rights reserved.23Copyright 2002-2006 Python Software Foundation. All rights reserved.24�)�annotationsN)�deque)�gettext)�ngettext�)�FLAG_NEEDS_VALUE��UNSET)�BadArgumentUsage)�BadOptionUsage)�NoSuchOption)�25UsageError)�T_FLAG_NEEDS_VALUE)�T_UNSET)�Argument)�Context)�Option)�	Parameter�Vc�X^�[U5n[U5n/nSmSU4SjjnU(a�U"U5nUcMUS:XaURU"U55 O�US:�aN[U5Vs/sH26oS"U5PM nnTbUR5 UR[	U55 O4US:a.Tb[S5e[
U5mUR[5 U(aM�Tb'[	U5UT'/n[UTS-S5UTS-S&[	U5[U54$s snf)axGiven an iterable of arguments and an iterable of nargs specifications,27it returns a tuple with all the unpacked arguments at the first index28and all remaining arguments as the second.29 30The nargs specification is the number of arguments that should be consumed31or `-1` to indicate that this position should eat up all the remainders.32 33Missing items are filled with ``UNSET``.34Nc�x>�TcUR5$UR5$![a	 [s$f=f�N)�popleft�pop�35IndexErrorr36)�c�sposs ��RD:\code\apps\devtools\python\user_packages\Python313\site-packages\click/parser.py�_fetch�_unpack_args.<locals>._fetchDs8���	��|��y�y�{�"��u�u�w����	��L�	�s�&�&�9�9rrzCannot have two nargs < 0)rzdeque[V]�returnzV | T_UNSET)37r�append�range�reverse�tuple�	TypeError�lenr38�reversed�list)�args�39nargs_spec�rvr�nargs�_�xrs       @r�_unpack_argsr03s�����;�D��z�"�J�:<�B��D����z�"���=���A�:��I�I�f�T�l�#�
�Q�Y�',�U�|�4�|�!����|�A�4����	�	���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� � ��-5s�)D'c�p�USSnUR5(aSU4$USSU:Xa40USSUSS4$XSS4$)Nr��)�isalnum)�opt�firsts  r�41_split_optr7osT�����G�E��}�}����3�w��42�1�Q�x�5���2�A�w��A�B�����a�b�'�>��c�j�Ub
URcU$[U5up UURU53$r)�token_normalize_funcr7)r5�ctx�prefixs   r�_normalize_optr=xs=��43�{�c�.�.�6��44��S�/�K�F��X�c�.�.�s�3�4�5�5r8c�\�\rSrSrSSSjjr\S	Sj5rS45SjrSrg)�_Option�Nc���/Ul/Ul[5UlUH�n[	U5up�U(d[SUS35eURR
US5 [U5S:Xa,[U	5S:XaURRU5 MURRU5 URR
U5 M� UcSnX0l	X@l46XPlX`lXl
g)Nz$Invalid start character for option (�)rr�store)�_short_opts�47_long_opts�set�prefixesr7�48ValueError�addr'r"�dest�actionr-�const�obj)49�selfrM�optsrJrKr-rLr5r<�values50          r�__init__�_Option.__init__�s���������"%�%��
��C�&�s�O�M�F�� �#G��u�A�!N�O�O��M�M���f�Q�i�(��6�{�a��C��J�!�O�� � �'�'��,����&�&�s�+��
�
�!�!�&�)���>��F��	����51��52��r8c� �URS;$)N)rCr")rK)rNs r�takes_value�_Option.takes_value�s���{�{�1�1�1r8c��URS:XaXRUR'GO5URS:Xa%URURUR'GOURS:Xa6URR	UR/5RU5 O�URS:Xa@URR	UR/5RUR5 OjURS:XaAURR
URS5S-URUR'O[SURS	35eURRUR5 g)53NrC�store_constr"�append_const�countrrzunknown action '�')54rKrOrJrL�55setdefaultr"�getrH�orderrM)rNrP�states   r�process�_Option.process�s���;�;�'�!�$)�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��56�57�C�
�[�[�G�
#�$)�J�J�N�N�4�9�9�a�$@�1�$D�E�J�J�t�y�y�!��/����}�A�>�?�?�
�����4�8�8�$r8)rErDrKrLrJr-rMrG�NrN)rM�58CoreOptionrO�cabc.Sequence[str]rJ�59str | NonerKrdr-�intrL�t.Any | None)r!�bool)rPzt.Anyr^�
_ParsingStater!�None)	�__name__�60__module__�__qualname__�__firstlineno__rQ�propertyrTr_�__static_attributes__�r8rr?r?sf��"��"��
��!���	�61���
���B�2��2�
%r8r?c�8�\rSrSrSSSjjrSSjrSrg)	�	_Argument�c�(�X lX0lXlgr�rJr-rM�rNrMrJr-s    rrQ�_Argument.__init__�s���	��62��r8c���URS:�a�[U[R5(de[	SU55nU[U5:Xa[nO<US:wa6[[S5RURURS95eUS:Xa[nXRUR'URRUR5 g)Nrc3�:# �UHo[LdM
Sv� M g7f)rNr	)�.0r/s  r�	<genexpr>�$_Argument.process.<locals>.<genexpr>�s���7�5�a��J���5�s��	rz'Argument {name!r} takes {nargs} values.��namer-rp)r-�63isinstance�cabc�Sequence�sumr'r64rr.�formatrJrOr]r"rM)rNrPr^�holess    rr_�_Argument.process�s���65�:�:��>��e�T�]�]�3�3�3�3��7�5�7�7�E���E�66�"����!��&��?�@�G�G�!�Y�Y�d�j�j�H�����B�;��E� %�67�68�4�9�9��
�����4�8�8�$r8ruN�r)rM�CoreArgumentrJrdr-re)rPz0str | cabc.Sequence[str | None] | None | T_UNSETr^rhr!ri)rjrkrlrmrQr_rorpr8rrrrr�s(���69%�?�%��%�70�	%r8rrc��\rSrSrSSjrSrg)rh��c�:�0Ul/UlXl/Ulgr)rO�largs�rargsr])rNr�s  rrQ�_ParsingState.__init__�s��&(��	� "��71��72�*,��73r8)r�rOr]r�N)r��	list[str]r!ri)rjrkrlrmrQrorpr8rrhrh�s��-r8rhc���\rSrSrSrSSSjjrSSSjjrSSSjjrSSjrSSjr	SS	jr74SS75jrSSjrSSjr
SS
jrSrg)�
_OptionParser��a>The option parser is an internal class that is ultimately used to76parse options and arguments.  It's modelled after optparse and brings77a similar but vastly simplified API.  It should generally not be used78directly as the high level Click classes wrap it for you.79 80It's not nearly as extensible as optparse or argparse as it does not81implement features that are implemented on a higher level (such as82types or defaults).83 84:param ctx: optionally the :class:`~click.Context` where this parser85            should go with.86 87.. deprecated:: 8.288    Will be removed in Click 9.0.89Nc��XlSUlSUlUb"URUlURUl0Ul0UlSS1Ul/Ulg)NTF�-�--)r;�allow_interspersed_args�ignore_unknown_options�90_short_opt�	_long_opt�
_opt_prefixes�_args)rNr;s  rrQ�_OptionParser.__init__�s_����91.2��$�92-2��#��?�+.�+F�+F�D�(�*-�*D�*D�D�'�.0���-/���!�4�[���&(��93r8c	�<�UVs/sHn[XpR5PM nn[XX4XVS9nURR	UR945 URHnX�RU'M URHnX�RU'M gs snf)aJAdds a new option named `dest` to the parser.  The destination95is not inferred (unlike with optparse) and needs to be explicitly96provided.  Action can be any of ``store``, ``store_const``,97``append``, ``append_const`` or ``count``.98 99The `obj` can be used to identify the option in the order list100that is returned from the parser.101)rKr-rLN)102r=r;r?r��updaterGrDr�rEr�)	rNrMrOrJrKr-rLr5�options	         r�103add_option�_OptionParser.add_options���":>�>��#��s�H�H�-���>���D�u�R�����!�!�&�/�/�2��%�%�C�#)�O�O�C� �&��$�$�C�"(�N�N�3��%��?s�Bc�J�URR[XUS95 g)z�Adds a positional argument named `dest` to the parser.104 105The `obj` can be used to identify the option in the order list106that is returned from the parser.107)rJr-N)r�r"rrrvs    r�add_argument�_OptionParser.add_arguments��	
�108�109���)�C�%�@�Ar8c��[U5nURU5 URU5 URURUR4$![a, URbURR110(deNXf=f)a2Parses positional arguments and returns ``(values, args, order)``111for the parsed options and arguments as well as the leftover112arguments if there are any.  The order is a list of objects as they113appear on the command line.  If arguments appear multiple times they114will be memorized multiple times as well.115)	rh�_process_args_for_options�_process_args_for_argsrr;�resilient_parsingrOr�r])rNr*r^s   r�116parse_args�_OptionParser.parse_args&sz���d�#��	��*�*�5�1��'�'��.��z�z�5�;�;����3�3���	��x�x��t�x�x�'A�'A��(B�	�s�"A�3B�Bc��[URUR-URVs/sHo"RPM sn5up4[UR5HupVUR
X5U5 M XAl/Ulgs snfr)r0r�r�r�r-�	enumerater_)rNr^r/�pargsr*�idx�args       rr��$_OptionParser._process_args_for_args8sp��"��K�K�%�+�+�%����'D��A����'D�117���"�$�*�*�-�H�C��K�K��118�E�*�.�������(Es�B119 120c��UR(a�URRS5n[U5nUS:XagUSSUR;aUS:�aUR	X!5 OJUR121(aURRU5 OURRSU5 gUR(aM�gg)Nrr�r)	r�rr'r��
_process_optsr�r�r"�insert)rNr^r��arglens    rr��'_OptionParser._process_args_for_optionsCs����k�k��+�+�/�/�!�$�C���X�F��d�{���R�a��D�.�.�.�6�A�:��"�"�3�.��-�-����"�"�3�'����"�"�1�c�*���k�k�kr8c��XR;a,SSKJn U"XR5n[XURS9eURUnUR122(a2UbURRSU5 URXU5nO+Ub"[U[S5RUS95e[nURXs5 g)Nr)�get_close_matches)�
possibilitiesr;z&Option {name!r} does not take a value.)r~)r��difflibr�r
r;rTr�r��_get_value_from_staterr.r�r123r_)rNr5�explicit_valuer^r�r�r�rPs        r�_match_long_opt�_OptionParser._match_long_optgs����n�n�$�1�-�c�>�>�B�M��s�T�X�X�N�N�����$�����124�)����"�"�1�n�5��.�.�s�E�B�E�
�
'� ��Q�?�@�G�G�S�G�Q��
�125�E����u�$r8c��SnSnUSn/nUSSH�n[UU3UR5nURRU5n	US-
nU	(d7UR(aURU5 Mh[
X�RS9eU	R(aBU[U5:a URRSXS5 SnURX�U5n126O[n127U	RX�5 U(dM� O UR(a7U(a/URRUSRU535 ggg)NFrr)r;Tr2)r=r;r�r\r�r"r
rTr'r�r�r�r128r_r��join)rNr�r^�stop�ir<�unknown_options�chr5r�rPs           r�_match_short_opt�_OptionParser._match_short_opt�s%����
���Q������a�b�'�B� �F�8�B�4��$�(�(�;�C��_�_�(�(��-�F�
��F�A���.�.�#�*�*�2�.��"�3�H�H�5�5��!�!��s�3�x�<��K�K�&�&�q�#�b�'�2��D��2�2�3��F�����N�N�5�(��t��3�>�&�&�?��K�K���&��"�'�'�/�*B�)C�D�E�,;�&r8c�F�URn[UR5U:aGURR(a[129nU$[
U[SSU5RXS95eUS:Xa�URSnURR(a?[U[5(a*USSUR;a[U5S:�a[130nU$URRS5nU$[URSU5nURSU2	U$)Nz%Option {name!r} requires an argument.z+Option {name!r} requires {nargs} arguments.r}rr)r-r'r�rM�_flag_needs_valuerrrr�r�strr�rr%)rN�option_namer�r^r-rP�	next_rargs       rr��#_OptionParser._get_value_from_state�s�������u�{�{��e�#��z�z�+�+�(��8��5%���?�E����f�+�f�;�
���a�Z����A��I��131�132�,�,��y�#�.�.��b�q�M�T�%7�%7�7��	�N�Q�&�)����������*��133���%�+�+�f�u�-�.�E����F�U�F�#��r8c�X�SnSU;aURSS5upCOUn[X@R5nURXSU5 g![aV USSUR134;aUR
X5 gUR(deURRU5 gf=f)N�=rr3)135�splitr=r;r�r
r�r�r�r�r")rNr�r^r��long_opt�
norm_long_opts      rr��_OptionParser._process_opts�s������#�:�'*�y�y��a�'8�$�H�n��H�&�x���:�
�136	$�� � ���F���	$��2�A�w�d�0�0�0��%�%�c�1���.�.���K�K���s�#�	$�s�A	�	.B)�9-B)�(B))r�r�r�r�r�r;r�r)r;�Context | Noner!rira)rMrbrOrcrJrdrKrdr-rerLrfr!rir�)rMr�rJrdr-rer!ri)r*r�r!z7tuple[dict[str, t.Any], list[str], list[CoreParameter]])r^rhr!ri)r5r�r�rdr^rhr!ri)r�r�r^rhr!ri)r�r�r�r?r^rhr!z-str | cabc.Sequence[str] | T_FLAG_NEEDS_VALUE)rjrkrlrm�__doc__rQr�r�r�r�r�r�r�r�r�rorpr8rr�r��s���� )�:"��"�)�
�)�!�)��	)�137�)��
)��)�138�)�2B�4��4�	@�4�$	��H%��%�(2�%�;H�%�	
�%�<&F�P&��&�(/�&�8E�&�	6�&�P$r8r�c���SSKnUS;a)URSUS3[SS9 [5SU3$US:XaS	S139KJn URS[SS9 U$[
U5e)Nr>rr�	split_opt�OptionParser�ParsingState�
normalize_optz'parser.z\' is deprecated and will be removed in Click 9.0. The old parser is available in 'optparse'.r3)�140stacklevelr.�split_arg_stringr)r�zpImporting 'parser.split_arg_string' is deprecated, it will only be available in 'shell_completion' in Click 9.0.)�warnings�warn�DeprecationWarning�globals�shell_completionr��AttributeError)r~r�r�s   r�__getattr__r��s�������	�
�
��t�f�:�
:���		�	141��y�1�T�F��$�$��!�!�6��
�
�
=���		�	142� ��143��144�r8)r*rcr+zcabc.Sequence[int]r!zGtuple[cabc.Sequence[str | cabc.Sequence[str | None] | None], list[str]])r5r�r!ztuple[str, str])r5r�r;r�r!r�)r~r�r!�object)*r��145__future__r�collections.abc�abcr��typing�t�collectionsrrr.r�_utilsrr146�147exceptionsrrr
r�
TYPE_CHECKINGrr�corerr�rrrbr�
CoreParameter�TypeVarrr0r7r=r?rrrhr�r�rpr8r�<module>r�s����0#���� ��$��(�&�$�"��?�?�*��.��*�0��I�I�c�N��9!�148�9!�*<�9!�L�9!�x�6�3%�3%�l%�%�>-�-�W$�W$�tr8
codekingpro/portable-devtools · Team Ai