1. Ian Cordasco
  2. uritemplate

Commits

Ian Cordasco  committed 32e55ab

Add partial to the public API

  • Participants
  • Parent commits c0417ff
  • Branches master

Comments (0)

Files changed (2)

File uritemplate/api.py

View file
 
     """
     return URITemplate(uri).expand(var_dict, **kwargs)
+
+
+def partial(uri, var_dict=None, **kwargs):
+    """Partially expand the template with the given parameters.
+
+    If all of the parameters for the template are not given, return a
+    partially expanded template.
+
+    :param dict var_dict: Optional dictionary with variables and values
+    :param kwargs: Alternative way to pass arguments
+    :returns: :class:`URITemplate`
+
+    Example::
+
+        t = URITemplate('https://api.github.com{/end}')
+        t.partial()  # => URITemplate('https://api.github.com{/end}')
+
+    """
+    return URITemplate(uri).partial(var_dict, **kwargs)

File uritemplate/template.py

View file
 
         :param dict var_dict: Optional dictionary with variables and values
         :param kwargs: Alternative way to pass arguments
-        :returns: str
+        :returns: :class:`URITemplate`
 
         Example::