
    (ph                         S r SSKrSSKrSSKJr  SSKJr  \R                  " S5      rS\R                  \R                     S\R                  S\R                  4S	 jr " S
 S5      rg)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                 Z    U (       a#  U R                  5       nUR                  U5        U$ U$ N)copyupdate)r   r   optss      G/var/www/html/venv/lib/python3.13/site-packages/uritemplate/template.py_merger      s)     }}I    c                   H   \ rS rSrSrS\4S jrS\4S jrS\4S jrS\	S\
4S	 jrS\4S
 jrS\R                  S\
S\4S jr SS\R$                  \R                     S\R&                  S\4S jjr SS\R$                  \R                     S\R&                  SS 4S jjrSrg)URITemplate%   a  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                    Xl         [        R                  U R                   5       Vs/ s H*  n[        R                  " UR                  5       S   5      PM,     snU l        [        R                  " 5       U l	        U R                   H1  nUR                   H  nU R                  R                  U5        M      M3     g s  snf )Nr   )r   template_refinditerr   URIVariablegroups	variablesr   
OrderedSetvariable_namesadd)selfr   mvarnames        r   __init__URITemplate.__init__F   s    
 !))$((38
3   A/38

 )335>>C**##''- + "8
s   1B=r   c                     SU -  $ )NzURITemplate("%s") r   s    r   __repr__URITemplate.__repr__U   s    "T))r   c                     U R                   $ r	   )r   r%   s    r   __str__URITemplate.__str__X   s    xxr   otherc                 j    [        U[        5      (       d  [        $ U R                  UR                  :H  $ r	   )
isinstancer   NotImplementedr   )r   r+   s     r   __eq__URITemplate.__eq__[   s(    %--!!xx599$$r   c                 ,    [        U R                  5      $ r	   )hashr   r%   s    r   __hash__URITemplate.__hash__`   s    DHH~r   r   replacec                 @  ^ U R                   (       d  U R                  $ Un0 mU R                    H#  nTR                  UR                  U5      5        M%     SSS[        4U4S jjnSSS[        4U4S jjnU(       a  UOUn[
        R                  XpR                  5      $ )Nmatchzre.Match[str]r   c                 J   > TR                  U R                  5       S   S5      $ )Nr    )getr   )r7   expandeds    r   replace_all(URITemplate._expand.<locals>.replace_alln   s    <<q 1266r   c                 h   > U R                  5       S   nSU-  nTR                  U5      =(       d    U$ )Nr   z{%s})r   r:   )r7   match_groupr   r;   s      r   replace_partial,URITemplate._expand.<locals>.replace_partialq   s1    ,,.+K;&C<<,33r   )r   r   r   expandstrr   sub)	r   r   r5   	expansionvr<   r@   replace_funcr;   s	           @r   _expandURITemplate._expandc   s     ~~88O	%'AOOAHHY/0  	7 	73 	7	4? 	4s 	4
 +2{|XX66r   Nkwargsc                 8    U R                  [        X5      S5      $ )a  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)rH   r   r   r   rJ   s      r   rB   URITemplate.expandz   s    2 ||F84e<<r   c                 J    [        U R                  [        X5      S5      5      $ )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   rH   r   rL   s      r   partialURITemplate.partial   s    ( 4<<x(@$GHHr   )r   r   r   r	   )__name__
__module____qualname____firstlineno____doc__rC   r!   r&   r)   objectboolr/   intr3   r   VariableValueDictrH   tOptionalVariableValuerB   rO   __static_attributes__r$   r   r   r   r   %   s    >.C .*# * %F %t %
# 7 227=A7	72 <@=**X778= ((= 
	=: <@I**X778I ((I 
	I Ir   r   )rU   retypingrZ   uritemplater   r   compiler   r[   rY   r   r   r$   r   r   <module>rb      sn     
  "  jj%jj334)) DI DIr   