You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ian Stapleton Cordasco ad025bffcb
Merge pull request #90 from python-hyper/pre-commit-ci-update-config
1 week ago
.github/workflows Fix TOXENV specification in GitHub workflows 10 months ago
docs/source Add type annotations to uritemplate 10 months ago
tests Fix typo 7 months ago
uritemplate Bump version string sa well for 4.1.1 10 months ago
.gitignore Add type annotations to uritemplate 10 months ago
.mailmap Add .mailmap to map old name to new name 5 years ago
.pre-commit-config.yaml [] pre-commit autoupdate 1 week ago
.tool-versions Ensure setup-cfg-fmt does not re-add Py2 10 months ago
.travis.yml Update support for Python 3.7 & 3.8 3 years ago
AUTHORS.rst Update project for new organization home 5 years ago
HISTORY.rst Reflect intent to drop Python 2 support 10 months ago
LICENSE Update the project name in the LICENSE 3 years ago
LICENSE.APACHE Relicense 6 years ago
LICENSE.BSD Drop support for Python 3.5, 3.4, and 2.7 10 months ago Include individaul license files 6 years ago
README.rst Fix link to RFC 10 months ago
pyproject.toml Add type annotations to uritemplate 10 months ago
setup.cfg [] auto fixes from hooks 1 week ago Move to static configuration 10 months ago
tox.ini Ensure setup-cfg-fmt does not re-add Py2 10 months ago



Documentation -- GitHub -- Travis-CI

Simple python library to deal with URI Templates. The API looks like

from uritemplate import URITemplate, expand

# NOTE: URI params must be strings not integers

gist_uri = '{/gist_id}'
t = URITemplate(gist_uri)
# =>

# or
print(expand(gist_uri, gist_id='123456'))

# also
t.expand({'gist_id': '123456'})
print(expand(gist_uri, {'gist_id': '123456'}))

Where it might be useful to have a class

import requests

class GitHubUser(object):
    url = URITemplate('{/login}')
    def __init__(self, name):
        self.api_url = url.expand(login=name)
        response = requests.get(self.api_url)
        if response.status_code == 200:

When the module containing this class is loaded, GitHubUser.url is evaluated and so the template is created once. It's often hard to notice in Python, but object creation can consume a great deal of time and so can the re module which uritemplate relies on. Constructing the object once should reduce the amount of time your code takes to run.


pip install uritemplate


Modified BSD license