MCPcopy Index your code
hub / github.com/webpy/webpy / _match

Method _match

web/application.py:515–530  ·  view source on GitHub ↗
(self, mapping, value)

Source from the content-addressed store, hash-verified

513 return web.notfound()
514
515 def _match(self, mapping, value):
516 for pat, what in mapping:
517 if isinstance(what, application):
518 if value.startswith(pat):
519 f = lambda: self._delegate_sub_application(pat, what)
520 return f, None
521 else:
522 continue
523 elif isinstance(what, str):
524 what, result = utils.re_subm(rf"^{pat}\Z", what, value)
525 else:
526 result = utils.re_compile(rf"^{pat}\Z").match(value)
527
528 if result: # it's a match
529 return what, [x for x in result.groups()]
530 return None, None
531
532 def _delegate_sub_application(self, dir, app):
533 """Deletes request to sub application `app` rooted at the directory `dir`.

Callers 1

handleMethod · 0.95

Calls 2

matchMethod · 0.80

Tested by

no test coverage detected