MCPcopy Create free account
hub / github.com/encode/starlette / replace_params

Function replace_params

starlette/routing.py:93–104  ·  view source on GitHub ↗
(
    path: str,
    param_convertors: dict[str, Convertor[Any]],
    path_params: dict[str, str],
)

Source from the content-addressed store, hash-verified

91
92
93def replace_params(
94 path: str,
95 param_convertors: dict[str, Convertor[Any]],
96 path_params: dict[str, str],
97) -> tuple[str, dict[str, str]]:
98 for key, value in list(path_params.items()):
99 if "{" + key + "}" in path:
100 convertor = param_convertors[key]
101 value = convertor.to_string(value)
102 path = path.replace("{" + key + "}", value)
103 path_params.pop(key)
104 return path, path_params
105
106
107# Match parameters in URL paths, eg. '{param}', and '{param:int}'

Callers 4

url_path_forMethod · 0.85
url_path_forMethod · 0.85
url_path_forMethod · 0.85
url_path_forMethod · 0.85

Calls 4

replaceMethod · 0.80
itemsMethod · 0.45
to_stringMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected