diff options
author | Ian Cordasco <graffatcolmingov@gmail.com> | 2013-05-14 12:49:46 -0400 |
---|---|---|
committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2013-05-14 12:49:46 -0400 |
commit | e07a0fa8b777c466c1431edabb6027385d8e820f (patch) | |
tree | 4a9b6f827085c7f4a5f7f2646966a5cbae33b13c /README.rst | |
parent | b0f21f3794a6bb416278184c30416bb574f7f3e6 (diff) | |
download | uritemplates-e07a0fa8b777c466c1431edabb6027385d8e820f.tar.gz |
Add license and more info to the README
Diffstat (limited to 'README.rst')
-rw-r--r-- | README.rst | 36 |
1 files changed, 33 insertions, 3 deletions
@@ -1,8 +1,10 @@ uritemplate =========== -Simple python library to deal with `URI Templates`_. When complete the API -should look something like:: +Documentation_ -- GitHub_ -- BitBucket_ + +Simple python library to deal with `URI Templates`_. The API should looks +like:: from uritemplate import URITemplate, expand @@ -16,6 +18,34 @@ should look something like:: # also t.expand({'gist_id': 123456}) - expand(gist_uri, {'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('https://api.github.com/user{/login}') + def __init__(self, name): + self.api_url = url.expand(login=name) + response = requests.get(self.api_url) + if response.status_code == 200: + self.__dict__.update(response.json()) + +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. + +License +------- + +Modified BSD license_ + +.. _Documentation: https://uritemplate.rtfd.org/ +.. _GitHub: https://github.com/sigmavirus24/uritemplate +.. _BitBucket: https://bitbucket.org/icordasc/uritemplate .. _URI Templates: http://tools.ietf.org/html/rfc6570 +.. _license: ./LICENSE |