METADATA 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. Metadata-Version: 2.1
  2. Name: uritemplate
  3. Version: 4.1.1
  4. Summary: Implementation of RFC 6570 URI Templates
  5. Home-page: https://uritemplate.readthedocs.org
  6. Author: Ian Stapleton Cordasco
  7. Author-email: graffatcolmingov@gmail.com
  8. License: BSD 3-Clause License or Apache License, Version 2.0
  9. Keywords: rfc 6570 uri template
  10. Platform: UNKNOWN
  11. Classifier: Development Status :: 5 - Production/Stable
  12. Classifier: Intended Audience :: Developers
  13. Classifier: License :: OSI Approved
  14. Classifier: License :: OSI Approved :: Apache Software License
  15. Classifier: License :: OSI Approved :: BSD License
  16. Classifier: Programming Language :: Python
  17. Classifier: Programming Language :: Python :: 3
  18. Classifier: Programming Language :: Python :: 3.6
  19. Classifier: Programming Language :: Python :: 3.7
  20. Classifier: Programming Language :: Python :: 3.8
  21. Classifier: Programming Language :: Python :: 3.9
  22. Classifier: Programming Language :: Python :: 3.10
  23. Classifier: Programming Language :: Python :: Implementation :: CPython
  24. Requires-Python: >=3.6
  25. Description-Content-Type: text/x-rst
  26. License-File: LICENSE
  27. uritemplate
  28. ===========
  29. Documentation_ -- GitHub_ -- Travis-CI_
  30. Simple python library to deal with `URI Templates`_. The API looks like
  31. .. code-block:: python
  32. from uritemplate import URITemplate, expand
  33. # NOTE: URI params must be strings not integers
  34. gist_uri = 'https://api.github.com/users/sigmavirus24/gists{/gist_id}'
  35. t = URITemplate(gist_uri)
  36. print(t.expand(gist_id='123456'))
  37. # => https://api.github.com/users/sigmavirus24/gists/123456
  38. # or
  39. print(expand(gist_uri, gist_id='123456'))
  40. # also
  41. t.expand({'gist_id': '123456'})
  42. print(expand(gist_uri, {'gist_id': '123456'}))
  43. Where it might be useful to have a class
  44. .. code-block:: python
  45. import requests
  46. class GitHubUser(object):
  47. url = URITemplate('https://api.github.com/user{/login}')
  48. def __init__(self, name):
  49. self.api_url = url.expand(login=name)
  50. response = requests.get(self.api_url)
  51. if response.status_code == 200:
  52. self.__dict__.update(response.json())
  53. When the module containing this class is loaded, ``GitHubUser.url`` is
  54. evaluated and so the template is created once. It's often hard to notice in
  55. Python, but object creation can consume a great deal of time and so can the
  56. ``re`` module which uritemplate relies on. Constructing the object once should
  57. reduce the amount of time your code takes to run.
  58. Installing
  59. ----------
  60. ::
  61. pip install uritemplate
  62. License
  63. -------
  64. Modified BSD license_
  65. .. _Documentation: https://uritemplate.readthedocs.io/
  66. .. _GitHub: https://github.com/python-hyper/uritemplate
  67. .. _Travis-CI: https://travis-ci.org/python-hyper/uritemplate
  68. .. _URI Templates: https://tools.ietf.org/html/rfc6570
  69. .. _license: https://github.com/python-hyper/uritemplate/blob/master/LICENSE