
    +h                         d Z ddlZddlZddlmZ ddlmZ  ej        d          Zdej	        ej
                 dej
        dej
        fd	Z G d
 d          ZdS )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returnc                 `    | r+|                                  }|                    |           |S |S N)copyupdate)r   r   optss      X/var/www/html/e360mart/e360mart_env/lib/python3.11/site-packages/uritemplate/template.py_merger      s6      }}I    c                       e Zd ZdZdefdZdefdZdefdZdede	fdZ
defd	Zd
ej        de	defdZ	 dd
ej        ej                 dej        defdZ	 dd
ej        ej                 dej        dd fdZdS )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.

    uric                     || _         d t                              | j                   D             | _        t	          j                    | _        | j        D ]&}|j        D ]}| j                            |           'd S )Nc                 f    g | ].}t          j        |                                d                    /S )r   )r   URIVariablegroups).0ms     r   
<listcomp>z(URITemplate.__init__.<locals>.<listcomp>K   s?     8
 8
 8
  A//8
 8
 8
r   )r   template_refinditer	variablesr   
OrderedSetvariable_namesadd)selfr   varnames       r   __init__zURITemplate.__init__F   s    8
 8
 ))$(338
 8
 8

 )355> 	. 	.C* . .#''----.	. 	.r   r   c                     d| z  S )NzURITemplate("%s") r    s    r   __repr__zURITemplate.__repr__U   s    "T))r   c                     | j         S r	   )r   r&   s    r   __str__zURITemplate.__str__X   s	    xr   otherc                 Z    t          |t                    st          S | j        |j        k    S r	   )
isinstancer   NotImplementedr   )r    r*   s     r   __eq__zURITemplate.__eq__[   s)    %-- 	"!!x59$$r   c                 *    t          | j                  S r	   )hashr   r&   s    r   __hash__zURITemplate.__hash__`   s    DH~~r   r   replacec                    | j         s| j        S |}i | j         D ]*}                    |                    |                     +dddt          ffd}dddt          ffd}|r|n|}t
                              || j                  S )Nmatchzre.Match[str]r   c                 `                         |                                 d         d          S )Nr    )getr   )r4   expandeds    r   replace_allz(URITemplate._expand.<locals>.replace_alln   s$    <<q 12666r   c                 p    |                                  d         }d|z  }                    |          p|S )Nr   z{%s})r   r7   )r4   match_groupr!   r8   s      r   replace_partialz,URITemplate._expand.<locals>.replace_partialq   s6    ,,..+K;&C<<,,33r   )r   r   r   expandstrr   sub)	r    r   r2   	expansionvr9   r<   replace_funcr8   s	           @r   _expandzURITemplate._expandc   s     ~ 	8O	%' 	1 	1AOOAHHY//0000	7 	73 	7 	7 	7 	7 	7 	7	4? 	4s 	4 	4 	4 	4 	4 	4
 +2B{|TX666r   Nkwargsc                 J    |                      t          ||          d          S )am  Expand 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)rC   r   r    r   rD   s      r   r=   zURITemplate.expandz   s"    2 ||F8V44e<<<r   c                 d    t          |                     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)r   rC   r   rF   s      r   partialzURITemplate.partial   s*    ( 4<<x(@(@$GGHHHr   r	   )__name__
__module____qualname____doc__r>   r#   r'   r)   objectboolr.   intr1   r   VariableValueDictrC   tOptionalVariableValuer=   rH   r%   r   r   r   r   %   su        >.C . . . .*# * * * *    %F %t % % % %
#    7 27=A7	7 7 7 72 <@= =*X78= (= 
	= = = =: <@I I*X78I (I 
	I I I I I Ir   r   )rL   retypingrQ   uritemplater   r   compiler   rR   rP   r   r   r%   r   r   <module>rX      s      
			     " " " " " "            bj%%j34)    DI DI DI DI DI DI DI DI DI DIr   