diff options
author | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-08-23 16:20:14 -0500 |
---|---|---|
committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2016-08-23 16:20:14 -0500 |
commit | def5c821ba145aac450947f8eba7e57e484fe9de (patch) | |
tree | 4f3569971bbe3aa7a37bece34f9889d057b39ae0 /uritemplate/api.py | |
parent | 862e89fb5ccfee7764f84d2aa15ffd140a0dbbd4 (diff) | |
download | uritemplates-def5c821ba145aac450947f8eba7e57e484fe9de.tar.gz |
Add missing variables function
At some point the uritemplate module added a variables function. This
adds that interface to maintain compatibility.
Closes #26
Diffstat (limited to 'uritemplate/api.py')
-rw-r--r-- | uritemplate/api.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/uritemplate/api.py b/uritemplate/api.py index cbcec09..37c7c45 100644 --- a/uritemplate/api.py +++ b/uritemplate/api.py @@ -50,3 +50,22 @@ def partial(uri, var_dict=None, **kwargs): """ return URITemplate(uri).partial(var_dict, **kwargs) + + +def variables(uri): + """Parse the variables of the template. + + This returns all of the variable names in the URI Template. + + :returns: Set of variable names + :rtype: set + + Example:: + + variables('https://api.github.com{/end}) + # => {'end'} + variables('https://api.github.com/repos{/username}{/repository}') + # => {'username', 'repository'} + + """ + return set(URITemplate(uri).variable_names) |