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__/template.cpython-310.pyc
o

�h��@sjdZddlZddlZddlmZddlmZe�d�Zdej	ej
dej
dej
fd	d
�ZGdd�d�ZdS)
z�

uritemplate.template
====================

This module contains the essential inner workings of uritemplate.

What treasures await you:

- URITemplate class

You see a treasure chest of knowledge in front of you.
What do you do?
>

�N)�
orderedset)�variablez	{([^}]+)}�var_dict�	overrides�returncCs|r
|��}|�|�|S|S�N)�copy�update)rr�opts�r�G/usr/local/CyberCP/lib/python3.10/site-packages/uritemplate/template.py�_merges

r
c@s�eZdZdZdefdd�Zdefdd�Zdefdd	�Zd
ede	fdd�Z
defd
d�Zde
jde	defdd�Z	ddeje
jde
jdefdd�Z	ddeje
jde
jddfdd�ZdS)�URITemplatea	This parses the template and will be used to expand it.

    This is the most important object as the center of the API.

    Example::

        from uritemplate import URITemplate
        import requests


        t = URITemplate(
            'https://api.github.com/users/sigmavirus24/gists{/gist_id}'
        )
        uri = t.expand(gist_id=123456)
        resp = requests.get(uri)
        for gist in resp.json():
            print(gist['html_url'])

    Please note::

        str(t)
        # 'https://api.github.com/users/sigmavirus24/gists{/gistid}'
        repr(t)  # is equivalent to
        # URITemplate(str(t))
        # Where str(t) is interpreted as the URI string.

    Also, ``URITemplates`` are hashable so they can be used as keys in
    dictionaries.

    �uricCsP||_dd�t�|j�D�|_t��|_|jD]}|jD]}|j�|�qqdS)NcSsg|]}t�|��d��qS)r)r�URIVariable�groups)�.0�mrrr�
<listcomp>Ks��z(URITemplate.__init__.<locals>.<listcomp>)r�template_re�finditer�	variablesr�
OrderedSet�variable_names�add)�selfr�var�namerrr�__init__Fs
�


��zURITemplate.__init__rcCsd|S)NzURITemplate("%s")r�rrrr�__repr__UszURITemplate.__repr__cCs|jSr)rrrrr�__str__XszURITemplate.__str__�othercCst|t�stS|j|jkSr)�
isinstancer�NotImplementedr)rr"rrr�__eq__[s
zURITemplate.__eq__cCs
t|j�Sr)�hashrrrrr�__hash__`s
zURITemplate.__hash__r�replacecsv|js|jS|}i�|jD]
}��|�|��q
dddtf�fdd�}dddtf�fdd�}|r2|n|}t�||j�S)N�matchz
re.Match[str]rcs��|��dd�S)Nr�)�getr)r)��expandedrr�replace_allnsz(URITemplate._expand.<locals>.replace_allcs"|��d}d|}��|�p|S)Nrz{%s})rr+)r)�match_grouprr,rr�replace_partialqsz,URITemplate._expand.<locals>.replace_partial)rrr	�expand�strr�sub)rrr(�	expansion�vr.r0�replace_funcrr,r�_expandcs
zURITemplate._expandN�kwargscKs|�t||�d�S)amExpand the template with the given parameters.

        :param dict var_dict: Optional dictionary with variables and values
        :param kwargs: Alternative way to pass arguments
        :returns: str

        Example::

            t = URITemplate('https://api.github.com{/end}')
            t.expand({'end': 'users'})
            t.expand(end='gists')

        .. note:: Passing values by both parts, may override values in
                  ``var_dict``. For example::

                      expand('https://{var}', {'var': 'val1'}, var='val2')

                  ``val2`` will be used instead of ``val1``.

        F)r7r
�rrr8rrrr1zszURITemplate.expandcKst|�t||�d��S)a�Partially expand the template with the given parameters.

        If all of the parameters for the template are not given, return a
        partially expanded template.

        :param dict var_dict: Optional dictionary with variables and values
        :param kwargs: Alternative way to pass arguments
        :returns: :class:`URITemplate`

        Example::

            t = URITemplate('https://api.github.com{/end}')
            t.partial()  # => URITemplate('https://api.github.com{/end}')

        T)rr7r
r9rrr�partial�szURITemplate.partialr)�__name__�
__module__�__qualname__�__doc__r2rr r!�object�boolr%�intr'r�VariableValueDictr7�t�Optional�
VariableValuer1r:rrrrr&s<��
��
��
��
���r)
r>�re�typingrC�uritemplaterr�compilerrDrBr
rrrrr�<module>s

��
�