HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/uritemplate/__pycache__/variable.cpython-310.pyc
o

�hsG�
@s�UdZddlZddlZddlZddlZddlZej	e
eee
dfZej	ejeejeeje
efeje
efefZeje
efZej�ej�d�Zeje
ed<dZeje
ed<dZeje
ed<e�e��Zeje
ed	<Gd
d�dej�Zej ej!ej"ej#ej$ej%ej&ej'ej(ej)ej*ej+d�Z,ejeje
efed
<Gdd�d�Z-dej.deje/ej0ejeje
efffdd�Z1dej.de/fdd�Z2dej.de/fdd�Z3ddej4de
de5fdd�Z6dej.de
de
fdd�Z7dS) z�

uritemplate.variable
====================

This module contains the URIVariable class which powers the URITemplate class.

What treasures await you:

- URIVariable class

You see a hammer in front of you.
What do you do?
>

�Nz~-_.�_UNRESERVED_CHARACTERSz:/?#[]@�_GEN_DELIMSz!$&'()*+,;=�_SUB_DELIMS�_RESERVED_CHARACTERSc@s�eZdZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZ
dZd
Zdefdd�Zdefdd�Zdefdd�Zdedefdd�Zdedefdd�Zdejdefdd�Zededdfdd��ZdS) �Operator��+�#�.�/�;�?�&�=�,�!�@�|�returncCs$|tjkr	tdS|tjkrtSdS)N�%r)r�reservedr�fragment��self�r�G/usr/local/CyberCP/lib/python3.10/site-packages/uritemplate/variable.py�reserved_charactersGs



zOperator.reserved_characterscCsF|tjkrdS|tjkrdS|tjkrdS|tjks|tjkr!dSdS)aCIdentify the separator used during expansion.

        Per `Section 3.2.1. Variable Expansion`_:

        ======  ===========    =========
        Type    Separator
        ======  ===========    =========
                ``","``        (default)
        ``+``   ``","``
        ``#``   ``","``
        ``.``   ``"."``
        ``/``   ``"/"``
        ``;``   ``";"``
        ``?``   ``"&"``
        ``&``   ``"&"``
        ======  ===========    =========

        .. _`Section 3.2.1. Variable Expansion`:
            https://www.rfc-editor.org/rfc/rfc6570#section-3.2.1
        r
rrrr)r�label_with_dot_prefix�path_segment�path_style_parameter�form_style_query�form_style_query_continuationrrrr�expansion_separatorWs




zOperator.expansion_separatorcCs|tjkrdSt�t|j�S�Nr)rr�t�cast�str�valuerrrr�variable_prefix�s
zOperator.variable_prefixr'cCs
t|d�Sr#��quote�rr'rrr�
_always_quote�s
zOperator._always_quotecCstj�|�|kr
t|t�S|S�N)�urllib�parse�unquoter*rr+rrr�_only_quote_unquoted_characters�s
z(Operator._only_quote_unquoted_characterscCsPt|ttf�st|�}t|t�r|��}|tjks|tjkr#|�|�S|�|�Sr-)	�
isinstancer&�bytes�decoderrrr1r,r+rrrr*�s


zOperator.quote�scCst�|tj�Sr-)�
_operators�getr�default)r5rrr�from_string�szOperator.from_stringN)�__name__�
__module__�__qualname__r8rrrrrr r!�reserved_eq�reserved_comma�
reserved_bang�reserved_at�
reserved_piper&rr"r(r,r1r$�Anyr*�staticmethodr9rrrrr+s.�4

r)rr	r
rrr
rrrrrrr6c@seZdZdZdefdd�Zdefdd�Zdefdd	�Zddd�Zd
ede	de
deje
dejef
dd�Zd
ede	de
deje
dejef
dd�Zd
ede	de
deje
dejef
dd�Zd
ede	de
deje
dejef
dd�Z	
ddejedejeeffdd�Zd
S)�URIVariableaThis object validates everything inside the URITemplate object.

    It validates template expansions and will truncate length as decided by
    the template.

    Please note that just like the :class:`URITemplate <URITemplate>`, this
    object's ``__str__`` and ``__repr__`` methods do not return the same
    information. Calling ``str(var)`` will return the original variable.

    This object does the majority of the heavy lifting. The ``URITemplate``
    object finds the variables in the URI and then creates ``URIVariable``
    objects.  Expansions of the URI are handled by each ``URIVariable``
    object. ``URIVariable.expand()`` returns a dictionary of the original
    variable and the expanded value. Check that method's documentation for
    more information.

    �varcCs,||_tj|_g|_g|_i|_|��dSr-)�originalrr8�operator�	variables�variable_names�defaultsr/)rrErrr�__init__�s�zURIVariable.__init__rcCsd|S)NzURIVariable(%s)rrrrr�__repr__�szURIVariable.__repr__cCs|jSr-)rFrrrr�__str__�szURIVariable.__str__Nc
Cs�|j}|jd}tvrt�|�|_|jdd�}|�d�}|D]E}d}|}d|vr4t|�dd��\}}|�d�}|�d�}d}d|vrSt|�dd��\}}	t	|	d�}|rZ||j
|<|j�|||d	�f�q d
d�|jD�|_
dS)z�Parse the variable.

        This finds the:
            - operator,
            - set of safe characters,
            - variables, and
            - defaults.

        r�Nrr�*�:�
)�explode�prefixcSsg|]\}}|�qSrr)�.0�varname�_rrr�
<listcomp>
sz%URIVariable.parse.<locals>.<listcomp>)rFr6rr9rG�split�tuple�endswith�rstrip�intrJrH�appendrI)
r�var_list_str�operator_str�var_listrE�default_val�namerRrS�
prefix_strrrrr/�s,





�zURIVariable.parserbr'rRrScs`|durdSt|�\}}|j���|jj�t|�rM|sM|sdSt�tjt|�}|r:|j�	��
��fdd�|D��Sd�
�fdd�|D��}��d|��St|�sS|r�|sWdSt�tjt
tf|�}|pit|���}|r||j�	��
��fdd�|D��Sd�
��fdd�|D��}��d|��S|r�t�tj|�}|r�|d|�n|}��d�|���S�dS)	z/Expansion method for the '?' and '&' operators.Nc3s"�|]}��d�|���VqdS�rNr�rT�v)�_quoterbrr�	<genexpr>#s�
�z/URIVariable._query_expansion.<locals>.<genexpr>rc3s�|]}�|�VqdSr-rre)rgrrrh's�rc3�,�|]\}}t|���d�|���VqdSrdr)�rT�krf�rg�saferrrh0��
�c3ri)rNr)rjrlrrrh4rn)�is_list_of_tuplesrGrr*�	list_testr$r%�Sequence�ScalarVariableValuer"�join�	dict_test�Mappingr&�sorted�items�Text�rrbr'rRrS�tuplesrwr)rgrbrmr�_query_expansionsB
���zURIVariable._query_expansionc
s,�j��}�j���|dust|ttttf�st|�dkrdSt	|�\}}t
|�rJ|sJ|s/d}t�tj
t|�}�fdd�|D�}|rH|�|�SdSt|�sP|rt�tjttf|�}|pbt|���}d�|skd�d}|����fdd	�|D��}	|	r}|	SdSt�tj|�}|r�|d|�n|}�j�|�S)
zSLabel and path expansion method.

        Expands for operators: '/', '.'

        Nrrcs g|]}|dur�j�|��qSr-�rGr*rerrrrW[sz5URIVariable._label_path_expansion.<locals>.<listcomp>�%s=%s�%s,%sc3s6�|]\}}|dur�t|���j�|�fVqdSr-�r*rGrj��
format_strrmrrrrhhs���z4URIVariable._label_path_expansion.<locals>.<genexpr>)rGr"rr2r&r\�float�complex�lenrorpr$r%rqrrrsrtrurvrwrxr*)
rrbr'rRrS�join_strrzrw�	fragments�expandedrr�r�_label_path_expansion?s<

�
��z!URIVariable._label_path_expansionc	sR�j��}�j���|durdSt|�\}}t|�rM|sMt�tjt|�}|r:|�	��fdd�|D��}|r8|SdSd�	�fdd�|D��}��d|��St
|�sS|r�t�tjttf|�}|pet
|���}|ru|�	��fdd�|D��Sd�	��fdd�|D��}��d|��St�tj|�}|r�|d|�n|}|r���d�j�|���S�S)	z"Expansion method for ';' operator.Nc3s,�|]}|dur��dt|����VqdS�Nrr)re)rbrmrrrh�s�"�z3URIVariable._semi_path_expansion.<locals>.<genexpr>rc3s�|]}t|��VqdSr-r)re)rmrrrh�s�rc3�8�|]\}}|durt|���d�j�|���VqdSr�rrj�rmrrrrh�����c3r�)Nrrrjr�rrrh�r�)rGr"rrorpr$r%rqrrrsrtrur&rvrwrxr*)	rrbr'rRrSr�rzrwr�r)rbrmrr�_semi_path_expansionss<

���z URIVariable._semi_path_expansioncs�|durdSt|�\}}t|�r'|s't�tjt|�}d��fdd�|D��St|�s-|rSt�tjt	tf|�}|p?t
|���}|rDdnd�d���fdd�|D��St�tj|�}|rb|d|�n|}�j
�|�S)Nrc3s�|]	}�j�|�VqdSr-r|rerrrrh�s�z0URIVariable._string_expansion.<locals>.<genexpr>r}r~c3s0�|]\}}��j�|��j�|�fVqdSr-r|rj�r�rrrrh�s
��
�)rorpr$r%rqrrrsrtrur&rvrwrxrGr*ryrr�r�_string_expansion�s �zURIVariable._string_expansion�var_dictcCsg}|dur|j|jiS|jD]b\}}|�|d�}|s)|dkr)||jvr)|j|}|dur.qd}|jtjks<|jtjkr@|j}n|jtj	ksL|jtj
krP|j}n
|jtjkrZ|j
}n|j}||||d|d�}|durq|�|�qd}|r�|j��|j���|�}|j|iS)a1Expand the variable in question.

        Using ``var_dict`` and the previously parsed defaults, expand this
        variable and subvariables.

        :param dict var_dict: dictionary of key-value pairs to be used during
            expansion
        :returns: dict(variable=value)

        Examples::

            # (1)
            v = URIVariable('/var')
            expansion = v.expand({'var': 'value'})
            print(expansion)
            # => {'/var': '/value'}

            # (2)
            v = URIVariable('?var,hello,x,y')
            expansion = v.expand({'var': 'value', 'hello': 'Hello World!',
                                  'x': '1024', 'y': '768'})
            print(expansion)
            # => {'?var,hello,x,y':
            #     '?var=value&hello=Hello%20World%21&x=1024&y=768'}

        NrrRrS)rFrHr7rJrGrrrr�r r!r{rr�r�r]r(r"rs)rr��
return_valuesrb�optsr'r��	expansionrrr�expand�s<

���
zURIVariable.expand)rNr-)r:r;r<�__doc__r&rKrLrMr/�
VariableValue�boolr$�Optionalr\r{r�r�r��VariableValueDictrur�rrrrrD�sp
*����
�0����
�4����
�4����
����rDr'rcCs0|rt|ttf�rtdd�|D��sdSd|fS)Ncss&�|]}t|t�ot|�dkVqdS)�N)r2rYr�)rTr$rrrrhs�$z$is_list_of_tuples.<locals>.<genexpr>)FNT)r2�listrY�all�r'rrrros���rocCst|ttf�Sr-)r2r�rYr�rrrrp#srpcCst|ttjjf�Sr-)r2�dict�collections�abc�MutableMappingr�rrrrt'srt�utf-8�encodingcCst|t�r
|�|�S|Sr-)r2r&�encode)r'r�rrr�_encode+s

r�rmcCs(t|ttf�st|�}tj�t|�|�Sr-)r2r&r3r.r/r*r�)r'rmrrrr*1sr*)r�)8r��collections.abcr��enum�string�typingr$�urllib.parser.�Unionr\r�r�r&rrrq�Listru�Tupler��Dictr��
ascii_letters�digitsr�Final�__annotations__rrr�Enumrrrrrrr r!r?rAr@r=r>r6rDrBr�r�rorprt�AnyStrr3r�r*rrrr�<module>s`����\�"
�