�
��fa� � � � d Z ddlZddlZddlmZ ddlmZ ej d� � Zdej ej
dej
dej
fd �Z G 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 �` � | r+| � � � }|� |� � |S |S �N)�copy�update)r r �optss �6/usr/lib/python3/dist-packages/uritemplate/template.py�_merger s6 � � � ��}�}�������I�������� c �� � e Zd ZdZdefd�Zdefd�Zdefd�Zdede fd�Z
defd �Zd
e
j de defd�Z dd
ej e
j de
j defd�Z dd
ej e
j de
j dd fd�Zd
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__zURITemplate.__init__F s� � ����8
� 8
� �)�)�$�(�3�3�8
� 8
� 8
���
)�3�5�5����>� .� .�C��*�
.�
.���#�'�'��-�-�-�-�
.� .� .r r c � � d| z S )NzURITemplate("%s")� �r s r
�__repr__zURITemplate.__repr__U s
� �"�T�)�)r c � � | j S r )r r& |