Server : LiteSpeed
System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64
User : nandedex ( 1060)
PHP Version : 8.1.33
Disable Function : NONE
Directory :  /opt/cppython/lib/python3.8/site-packages/uritemplate/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]


Current File : //opt/cppython/lib/python3.8/site-packages/uritemplate/__pycache__/template.cpython-38.pyc
U

N��g��@sfdZddlZddlZddlmZddlmZe�d�Zej	ej
ej
ej
d�dd�ZGd	d
�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�A/opt/cppython/lib/python3.8/site-packages/uritemplate/template.py�_merges

r
c@s�eZdZdZed�dd�Zed�dd�Zed�dd	�Zee	d
�dd�Z
ed�d
d�Ze
je	ed�dd�Zdeje
je
jed�dd�Zdeje
je
jdd�dd�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�|�q8q.dS)NcSsg|]}t�|��d��qS)r)rZURIVariable�groups)�.0�mrrr�
<listcomp>Ks�z(URITemplate.__init__.<locals>.<listcomp>)r�template_re�finditer�	variablesrZ
OrderedSetZvariable_names�add)�selfr�var�namerrr�__init__Fs
�


zURITemplate.__init__)rcCsd|S)NzURITemplate("%s")r�rrrr�__repr__UszURITemplate.__repr__cCs|jSrrrrrr�__str__XszURITemplate.__str__)�otherrcCst|t�stS|j|jkSr)�
isinstancer�NotImplementedr)rr rrr�__eq__[s
zURITemplate.__eq__cCs
t|j�Sr)�hashrrrrr�__hash__`szURITemplate.__hash__)r�replacercsr|js|jS|}i�|jD]}��|�|��qdtd��fdd�}dtd��fdd�}|r`|n|}t�||j�S)Nz
re.Match[str])�matchrcs��|��dd�S)Nr�)�getr)r'��expandedrr�replace_allnsz(URITemplate._expand.<locals>.replace_allcs"|��d}d|}��|�p |S)Nrz{%s})rr))r'Zmatch_grouprr*rr�replace_partialqsz,URITemplate._expand.<locals>.replace_partial)rrr	�expand�strr�sub)rrr&Z	expansion�vr,r-Zreplace_funcrr*r�_expandcs
zURITemplate._expandN)r�kwargsrcKs|�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)r2r
�rrr3rrrr.zszURITemplate.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)rr2r
r4rrr�partial�szURITemplate.partial)N)N)�__name__�
__module__�__qualname__�__doc__r/rrr�object�boolr#�intr%r�VariableValueDictr2�t�OptionalZ
VariableValuer.r5rrrrr%s,��
��
�r)
r9�re�typingr>Zuritemplaterr�compilerr?r=r
rrrrr�<module>s

�

F1le Man4ger