%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/click/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/click/__pycache__/parser.cpython-312.pyc

�

D�d{J���dZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lmZejrddlZddlmZddlmZdd
lmZddlmZej0d�Ze�Zdej8edej8edej>ej8ej@eej8ejBedfejDeffd�Z#dedej>eeffd�Z$dedejBddefd�Z%dedejDefd�Z&Gd�d�ZGd�d�ZGd�d �Z'Gd!�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.
�N)�deque)�gettext)�ngettext�)�BadArgumentUsage)�BadOptionUsage)�NoSuchOption)�
UsageError)�Argument)�Context)�Option)�	Parameter�V�args�
nargs_spec�returnc�T��t|�}t|�}g}d�dddtjtf�fd�}|r�||�}|��
|dk(r|j	||��n~|dkDrKt|�D�cgc]
}||���}}��|j
�|j	t|��n.|dkr)��td��t|��|j	d�|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 `None`.
    N�czte.Deque[V]rc�h��	��|j�S|j�S#t$rYywxYw�N)�popleft�pop�
IndexError)r�sposs ��./usr/lib/python3/dist-packages/click/parser.py�_fetchz_unpack_args.<locals>._fetchBs6���	��|��y�y�{�"��u�u�w����	��	�s�%�%�	1�1rrzCannot have two nargs < 0)r�t�Optionalr�append�range�reverse�tuple�	TypeError�len�reversed�list)rr�rvr�nargs�_�xrs       @r�_unpack_argsr+1s0�����;�D��z�"�J�DF�B� �D��-��A�J�J�q�M����z�"���=���A�:��I�I�f�T�l�#�
�Q�Y�',�U�|�4�!����4�A�4����	�	���I�I�e�A�h��
�Q�Y���� ;�<�<��r�7�D��I�I�d�O�-�4����;��4����!�"�T�A�X�Z�.�1��4�!�8�:����9�d�4�j� � ��-5s�7D%�optc�f�|dd}|j�rd|fS|dd|k(r
|dd|ddfS||ddfS)Nr��)�isalnum)r,�firsts  r�	split_optr2msT�����G�E��}�}���3�w��
�1�Q�x�5���2�A�w��A�B�����#�a�b�'�>���ctxrc�h�|�|j�|St|�\}}|�|j|���Sr)�token_normalize_funcr2)r,r4�prefixs   r�
normalize_optr8vs?��
�{�c�.�.�6��
��C�.�K�F�C��X�c�.�.�s�3�4�5�5r3�stringc���ddl}|j|d��}d|_d|_g}	|D]}|j|��	|S#t$r|j|j
�Y|SwxYw)a�Split an argument string as with :func:`shlex.split`, but don't
    fail if the string is incomplete. Ignores a missing closing quote or
    incomplete escape sequence and uses the partial token as-is.

    .. code-block:: python

        split_arg_string("example 'my file")
        ["example", "my file"]

        split_arg_string("example my\")
        ["example", "my"]

    :param string: String to split.
    rNT)�posixr.)�shlex�whitespace_split�
commentersr�
ValueError�token)r9r<�lex�outr@s     r�split_arg_stringrC}s|���
�+�+�f�D�+�
)�C��C���C�N�
�C���	�E��J�J�u��	��J��
��	�
�
�3�9�9���J�
�s�A�$A,�+A,c���eZdZ			ddddejedejedejededejejfd	�Z	e
d
efd��Zdejd
dd
dfd�Z
y)r
N�obj�
CoreOption�opts�dest�actionr(�constc���g|_g|_t�|_|D]�}t	|�\}}	|std|�d���|jj
|d�t|�dk(r*t|	�dk(r|jj|��x|jj|�|jj
|���|�d}||_	||_
||_||_||_
y)Nz$Invalid start character for option (�)rr�store)�_short_opts�
_long_opts�set�prefixesr2r?�addr$rrHrIr(rJrE)
�selfrErGrHrIr(rJr,r7�values
          r�__init__zOption.__init__�s���������$'�E��
��		*�C�%�c�N�M�F�E�� �#G��u�A�!N�O�O��M�M���f�Q�i�(��6�{�a��C��J�!�O�� � �'�'��,����&�&�s�+��
�
�!�!�&�)�		*��>��F���	������
���
���r3rc��|jdvS)N)rMr)rI)rSs r�takes_valuezOption.takes_value�s���{�{�1�1�1r3rT�state�ParsingStatec��|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)
NrM�store_constr�append_const�countrrzunknown action '�')
rIrGrHrJ�
setdefaultr�getr?�orderrE)rSrTrXs   r�processzOption.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�$r3�NrN)�__name__�
__module__�__qualname__r�Sequence�strr�int�AnyrU�property�boolrWrb�r3rr
r
�s���#'��#'��
���j�j��o���j�j��o�	�
�
�
�3����
��z�z�!�%�%� ��B�2�T�2��2�
%�Q�U�U�
%�>�
%�d�
%r3r
c��eZdZddddejedefd�Zdejejeejejefddd	d
fd�Z
y
)
rrE�CoreArgumentrHr(c�.�||_||_||_yr)rHr(rE�rSrErHr(s    rrUzArgument.__init__�s����	���
���r3rTrXrYrNc��|jdkDre|�J�td�|D��}|t|�k(rd}n>|dk7r9tt	d�j|j|j����|jdk(r|jj�|dk(rd}||j|j<|jj|j�y)Nrc3�&K�|]	}|��d���y�w)Nrrm)�.0r*s  r�	<genexpr>z#Argument.process.<locals>.<genexpr>�s����6�a�A�I��6�s��rz'Argument {name!r} takes {nargs} values.��namer(���rm)r(�sumr$rr)�formatrHrE�envvarrGrar)rSrTrX�holess    rrbzArgument.process�s���
�:�:��>��$�$�$��6�5�6�6�E���E�
�"����!��&��?�@�G�G�!�Y�Y�d�j�j�H�����:�:�������� ;�����E� %��
�
�4�9�9��
�����4�8�8�$r3�r)rdrerfrrrhrirU�Unionrgrbrmr3rrr�sl���N��!�*�*�S�/��#��
%��w�w�q�z�z�#���
�
�1�:�:�c�?�(C�C�D�%��%�
�	%r3rc�6�eZdZdejeddfd�Zy)rY�rargsrNc�<�i|_g|_||_g|_yr)rG�largsr�ra)rSr�s  rrUzParsingState.__init__�s��(*��	�"$��
���
�.0��
r3)rdrerfr�ListrhrUrmr3rrYrY�s��1�a�f�f�S�k�1�d�1r3rYc�p�eZdZdZd dej
dddfd�Z			d!ddd	ejed
ej
edej
ede	d
ej
ejddfd�Z	d"ddd
ej
ede	ddfd�Zdejedejejeejfejeejdffd�Zdeddfd�Zdeddfd�Zdedej
ededdfd�Zdededdfd�Zdedededejfd�Zdededdfd�Zy)#�OptionParsera+The 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.
    Nr4rrc��||_d|_d|_|�"|j|_|j|_i|_i|_ddh|_g|_y)NTF�-�--)r4�allow_interspersed_args�ignore_unknown_options�
_short_opt�	_long_opt�
_opt_prefixes�_args)rSr4s  rrUzOptionParser.__init__sa�����
.2��$�
-2��#��?�+.�+F�+F�D�(�*-�*D�*D�D�'�/1���.0���!�4�[���')��
r3rErFrGrHrIr(rJc�@�|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.
        )rIr(rJN)
r8r4r
r��updaterQrNr�rOr�)	rSrErGrHrIr(rJr,�options	         r�
add_optionzOptionParser.add_option#s���"9=�=��
�c�4�8�8�,�=��=���T�4��e�5�Q�����!�!�&�/�/�2��%�%�	*�C�#)�D�O�O�C� �	*��$�$�	)�C�"(�D�N�N�3��	)��>s�Broc�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.
        )rHr(N)r�rrrqs    r�add_argumentzOptionParser.add_argument<s��	
�
�
���(�3�T��?�@r3r�
CoreParameterc��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
        arguments if there are any.  The order is a list of objects as they
        appear on the command line.  If arguments appear multiple times they
        will be memorized multiple times as well.
        )	rY�_process_args_for_options�_process_args_for_argsr
r4�resilient_parsingrGr�ra)rSrrXs   r�
parse_argszOptionParser.parse_argsFsz���T�"��	��*�*�5�1��'�'��.��z�z�5�;�;����3�3���	��x�x��t�x�x�'A�'A��(B�	�s�"A�,B�BrXc��t|j|jz|jD�cgc]}|j��c}�\}}t|j�D]\}}|j
|||��||_g|_ycc}wr)r+r�r�r�r(�	enumeraterb)rSrXr*�pargsr�idx�args       rr�z#OptionParser._process_args_for_argsXs{��"��K�K�%�+�+�%����'D�A����'D�
���t�"�$�*�*�-�	+�H�C���K�K��c�
�E�*�	+��������(Es�B

c�l�|jr�|jjd�}t|�}|dk(ry|dd|jvr|dkDr|j	||�nE|j
r|jj|�n|jjd|�y|jr��yy)Nrr�r)	r�rr$r��
_process_optsr�r�r�insert)rSrXr��arglens    rr�z&OptionParser._process_args_for_optionscs����k�k��+�+�/�/�!�$�C���X�F��d�{���R�a��D�.�.�.�6�A�:��"�"�3��.��-�-����"�"�3�'����"�"�1�c�*���k�kr3r,�explicit_valuec��||jvr1ddlm}|||j�}t|||j���|j|}|j
r2|�|jjd|�|j|||�}n)|�%t|td�j|����d}|j||�y)Nr)�get_close_matches)�
possibilitiesr4z&Option {name!r} does not take a value.)rw)
r��difflibr�r	r4rWr�r��_get_value_from_staterr)rzrb)rSr,r�rXr�r�r�rTs        r�_match_long_optzOptionParser._match_long_opt�s����d�n�n�$�1�-�c�4�>�>�B�M��s�-�T�X�X�N�N�����$�����
�)����"�"�1�n�5��.�.�s�F�E�B�E�
�
'� ��Q�?�@�G�G�S�G�Q��
�
�E����u�e�$r3r�c�Z�d}d}|d}g}|ddD]�}t|�|��|j�}|jj|�}	|dz
}|	s5|jr|j|��]t
||j���|	jrC|t|�kr!|jjd||d�d}|j||	|�}
nd}
|	j|
|�|s��n|jr2|r/|jj|�dj|����yyy)NFrr)r4Tr.)r8r4r�r`r�rr	rWr$r�r�r�rbr��join)rSr�rX�stop�ir7�unknown_options�chr,r�rTs           r�_match_short_optzOptionParser._match_short_opt�s0����
���Q������a�b�'�	�B��6�(�2�$�����:�C��_�_�(�(��-�F�
��F�A���.�.�#�*�*�2�.��"�3�D�H�H�5�5��!�!��s�3�x�<��K�K�&�&�q�#�a�b�'�2��D��2�2�3���F�����N�N�5�%�(���3	�>�&�&�?��K�K���&��"�'�'�/�*B�)C�D�E�,;�&r3�option_namer�c�$�|j}t|j�|krF|jjrt}|St|t
dd|�j||����|dk(ry|jd}|jjr7t|t�r'|dd|jvrt|�dkDrt}|S|jjd�}|St|jd|�}|jd|�=|S)Nz%Option {name!r} requires an argument.z+Option {name!r} requires {nargs} arguments.rvrr)
r(r$r�rE�_flag_needs_valuerrrz�
isinstancerhr�rr")rSr�r�rXr(rT�	next_rargs       rr�z"OptionParser._get_value_from_state�s�������u�{�{��e�#��z�z�+�+�)��8��5%���?�E����f�+�U�f�;�
���a�Z����A��I��
�
�,�,��y�#�.��b�q�M�T�%7�%7�7��	�N�Q�&�*����������*��
���%�+�+�f�u�-�.�E����F�U�F�#��r3c�L�d}d|vr|jdd�\}}n|}t||j�}	|j|||�y#t$rP|dd|j
vr|j
||�Yy|js�|jj|�YywxYw)N�=rr/)
�splitr8r4r�r	r�r�r�r�r)rSr�rXr��long_opt�
norm_long_opts      rr�zOptionParser._process_opts�s������#�:�'*�y�y��a�'8�$�H�n��H�%�h����9�
�
	$�� � ����F���	$��2�A�w�d�0�0�0��%�%�c�5�1���.�.���K�K���s�#�	$�s�A
�
,B#�8(B#�"B#rrcr})rdrerf�__doc__rrrUrgrhrirjr�r�r��Tuple�Dictr�rYr�r�r�r�r
r�r�rmr3rr�r��s����*�A�J�J�y�1�*�T�*�:#'��#'�)�
�)��j�j��o�)��j�j��o�	)�
�
�
�3��)��
)��z�z�!�%�%� �)�
�)�4HI�A�!�A�)*���C��A�AD�A�	
�A�4��F�F�3�K�4�	
�������Q�U�U�
�#�Q�V�V�C�[�!�&�&��2I�I�	J�4�$	�L�	�T�	��|����H%��%�()�
�
�3��%�@L�%�	
�%�<&F�C�&F��&F��&F�P$��$�(.�$�7C�$�	
���$�L$��$�\�$�d�$r3r�))r��typingr�collectionsrrr)r�
exceptionsrrr	r
�
TYPE_CHECKING�typing_extensions�te�corerrorr
rFrr��TypeVarr�objectr�rgrhrir�r~rr�r+r2r8rCrYr�rmr3r�<module>r�sM���.�� ��(�&�$�"��?�?�"�.��*�0�
�A�I�I�c�N��
�H��9!�
�*�*�S�/�9!�'(�z�z�#��9!��W�W�Q�Z�Z�����Q�Z�Z��
�
�3��%@�$� F�G�
H�!�&�&�QT�+�
U�V�9!�x�3��1�7�7�3��8�,��6�s�6����I�!6�6�3�6��S��Q�V�V�C�[��D3%�3%�l%�%�@1�1�T$�T$r3

Zerion Mini Shell 1.0