OLD | NEW |
(Empty) | |
| 1 uritemplate |
| 2 =========== |
| 3 |
| 4 .. image:: https://secure.travis-ci.org/uri-templates/uritemplate-py.png?branch=
master |
| 5 :alt: build status |
| 6 :target: http://travis-ci.org/uri-templates/uritemplate-py |
| 7 |
| 8 This is a Python implementation of `RFC6570`_, URI Template, and can |
| 9 expand templates up to and including Level 4 in that specification. |
| 10 |
| 11 It exposes a method, *expand*. For example: |
| 12 |
| 13 .. code-block:: python |
| 14 |
| 15 >>> from uritemplate import expand |
| 16 >>> expand("http://www.{domain}/", {"domain": "foo.com"}) |
| 17 'http://www.foo.com/' |
| 18 |
| 19 It also exposes a method *variables* that returns all variables used in a |
| 20 uritemplate. For example: |
| 21 |
| 22 .. code-block:: python |
| 23 |
| 24 >>> from uritemplate import variables |
| 25 >>> variables('http:www{.domain*}{/top,next}{?q:20}') |
| 26 >>> set(['domain', 'next', 'q', 'top']) |
| 27 |
| 28 This function can be useful to determine what keywords are available to be |
| 29 expanded. |
| 30 |
| 31 .. _RFC6570: http://tools.ietf.org/html/rfc6570 |
| 32 |
| 33 |
| 34 Requirements |
| 35 ------------ |
| 36 |
| 37 uritemplate works with Python 2.5+. |
| 38 |
| 39 .. note:: You need to install `simplejson`_ module for Python 2.5. |
| 40 |
| 41 .. _simplejson: https://pypi.python.org/pypi/simplejson/ |
| 42 |
| 43 |
| 44 Install |
| 45 ------- |
| 46 |
| 47 The easiest way to install uritemplate is with pip:: |
| 48 |
| 49 $ pip install uritemplate |
| 50 |
| 51 See its `Python Package Index entry`_ for more. |
| 52 |
| 53 .. _Python Package Index entry: http://pypi.python.org/pypi/uritemplate |
| 54 |
| 55 |
| 56 License |
| 57 ======= |
| 58 |
| 59 Copyright 2011-2013 Joe Gregorio |
| 60 |
| 61 Licensed under the Apache License, Version 2.0 (the "License"); |
| 62 you may not use this file except in compliance with the License. |
| 63 You may obtain a copy of the License at |
| 64 |
| 65 http://www.apache.org/licenses/LICENSE-2.0 |
| 66 |
| 67 Unless required by applicable law or agreed to in writing, software |
| 68 distributed under the License is distributed on an "AS IS" BASIS, |
| 69 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 70 See the License for the specific language governing permissions and |
| 71 limitations under the License. |
OLD | NEW |