|
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__/ |
U
N��g� � @ sf d Z ddlZddlZddlmZ ddlmZ e�d�Zej ej
ej
ej
d�dd�ZG d d
� d
�ZdS )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 C s | r| � � }|�|� |S |S �N)�copy�update)r r �opts� r �A/opt/cppython/lib/python3.8/site-packages/uritemplate/template.py�_merge s
r
c @ s� e Zd ZdZed�dd�Zed�dd�Zed�dd �Zee d
�dd�Z
ed�d
d�Ze
je ed�dd�Zdeje
j e
jed�dd�Zdeje
j e
jd d�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.
��uric C sP || _ dd� t�| j �D �| _t�� | _| jD ]}|jD ]}| j�|� q8q.d S )Nc S s g | ]}t �|�� d ��qS )r )r ZURIVariable�groups)�.0�mr r r �
<listcomp>K s �z(URITemplate.__init__.<locals>.<listcomp>)r �template_re�finditer� variablesr Z
OrderedSetZvariable_names�add)�selfr �var�namer r r �__init__F s
�
zURITemplate.__init__)r c C s d| S )NzURITemplate("%s")r �r r r r �__repr__U s zURITemplate.__repr__c C s | j S r r r r r r �__str__X s zURITemplate.__str__)�otherr c C s t |t�stS | j|jkS r )�
isinstancer �NotImplementedr )r r r r r �__eq__[ s
zURITemplate.__eq__c C s
t | j�S r )�hashr r r r r �__hash__` s zURITemplate.__hash__)r �replacer c sr | j s| jS |}i � | j D ]}� �|�|�� qdtd�� fdd�}dtd�� fdd�}|r`|n|}t�|| j�S )Nz
re.Match[str])�matchr c s � � | �� d d�S )Nr � )�getr )r'