MCPcopy
hub / github.com/pallets/werkzeug / is_endpoint_expecting

Method is_endpoint_expecting

src/werkzeug/routing/map.py:134–152  ·  view source on GitHub ↗

Iterate over all rules and check if the endpoint expects the arguments provided. This is for example useful if you have some URLs that expect a language code and others that do not and you want to wrap the builder a bit so that the current language code is automatica

(self, endpoint: t.Any, *arguments: str)

Source from the content-addressed store, hash-verified

132 self._matcher.merge_slashes = value
133
134 def is_endpoint_expecting(self, endpoint: t.Any, *arguments: str) -> bool:
135 """Iterate over all rules and check if the endpoint expects
136 the arguments provided. This is for example useful if you have
137 some URLs that expect a language code and others that do not and
138 you want to wrap the builder a bit so that the current language
139 code is automatically added if not provided but endpoints expect
140 it.
141
142 :param endpoint: the endpoint to check.
143 :param arguments: this function accepts one or more arguments
144 as positional arguments. Each one of them is
145 checked.
146 """
147 self.update()
148 arguments_set = set(arguments)
149 for rule in self._rules_by_endpoint[endpoint]:
150 if arguments_set.issubset(rule.arguments):
151 return True
152 return False
153
154 @property
155 def _rules(self) -> list[Rule]:

Callers

nothing calls this directly

Calls 1

updateMethod · 0.95

Tested by

no test coverage detected