MCPcopy Create free account
hub / github.com/python-hyper/uritemplate / expand

Function expand

uritemplate/api.py:19–44  ·  view source on GitHub ↗

Expand the template with the given parameters. :param str uri: The templated URI to expand :param dict var_dict: Optional dictionary with variables and values :param kwargs: Alternative way to pass arguments :returns: str Example:: expand('https://api.github.com{/end}'

(
    uri: str,
    var_dict: t.Optional[variable.VariableValueDict] = None,
    **kwargs: variable.VariableValue,
)

Source from the content-addressed store, hash-verified

17
18
19def expand(
20 uri: str,
21 var_dict: t.Optional[variable.VariableValueDict] = None,
22 **kwargs: variable.VariableValue,
23) -> str:
24 """Expand the template with the given parameters.
25
26 :param str uri: The templated URI to expand
27 :param dict var_dict: Optional dictionary with variables and values
28 :param kwargs: Alternative way to pass arguments
29 :returns: str
30
31 Example::
32
33 expand('https://api.github.com{/end}', {'end': 'users'})
34 expand('https://api.github.com{/end}', end='gists')
35
36 .. note:: Passing values by both parts, may override values in
37 ``var_dict``. For example::
38
39 expand('https://{var}', {'var': 'val1'}, var='val2')
40
41 ``val2`` will be used instead of ``val1``.
42
43 """
44 return URITemplate(uri).expand(var_dict, **kwargs)
45
46
47def partial(

Callers 2

test_expandMethod · 0.90
test_expandMethod · 0.90

Calls 2

URITemplateClass · 0.90
expandMethod · 0.45

Tested by 2

test_expandMethod · 0.72
test_expandMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…