MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / build

Method build

21-async/mojifinder/bottle.py:406–415  ·  view source on GitHub ↗

Build an URL by filling the wildcards in a rule.

(self, _name, *anons, **query)

Source from the content-addressed store, hash-verified

404 comborules.append((combined, rules))
405
406 def build(self, _name, *anons, **query):
407 ''' Build an URL by filling the wildcards in a rule. '''
408 builder = self.builder.get(_name)
409 if not builder: raise RouteBuildError("No route with that name.", _name)
410 try:
411 for i, value in enumerate(anons): query['anon%d'%i] = value
412 url = ''.join([f(query.pop(n)) if n else f for (n,f) in builder])
413 return url if not query else url+'?'+urlencode(query)
414 except KeyError:
415 raise RouteBuildError('Missing URL argument: %r' % _e().args[0])
416
417 def match(self, environ):
418 ''' Return a (target, url_agrs) tuple or raise HTTPError(400/404/405). '''

Callers 2

addMethod · 0.95
get_urlMethod · 0.45

Calls 5

RouteBuildErrorClass · 0.85
_eFunction · 0.85
popMethod · 0.80
fFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected