MCPcopy
hub / github.com/encode/starlette / replace_params

Function replace_params

starlette/routing.py:92–103  ·  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

90
91
92def replace_params(
93 path: str,
94 param_convertors: dict[str, Convertor[Any]],
95 path_params: dict[str, str],
96) -> tuple[str, dict[str, str]]:
97 for key, value in list(path_params.items()):
98 if "{" + key + "}" in path:
99 convertor = param_convertors[key]
100 value = convertor.to_string(value)
101 path = path.replace("{" + key + "}", value)
102 path_params.pop(key)
103 return path, path_params
104
105
106# 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