def match(self, environ):
path, targets, urlargs = environ['<STR_LIT>'] or '<STR_LIT:/>', None, {}<EOL>if path in self.static:<EOL><INDENT>targets = self.static[path]<EOL><DEDENT>else:<EOL><INDENT>for combined, rules in self.dynamic:<EOL><INDENT>match = combined.match(path)<EOL>if not match: continue<EOL>getargs, targets = rules[match.lastindex - <NUM_LIT:1>]<EOL>urlargs = getargs(path) if getargs else {}<EOL>break<EOL><DEDENT><DEDENT>if not targets:<EOL><INDENT>raise HTTPError(<NUM_LIT>, "<STR_LIT>" + repr(environ['<STR_LIT>']))<EOL><DEDENT>method = environ['<STR_LIT>'].upper()<EOL>if method in targets:<EOL><INDENT>return targets[method], urlargs<EOL><DEDENT>if method == '<STR_LIT>' and '<STR_LIT:GET>' in targets:<EOL><INDENT>return targets['<STR_LIT:GET>'], urlargs<EOL><DEDENT>if '<STR_LIT>' in targets:<EOL><INDENT>return targets['<STR_LIT>'], urlargs<EOL><DEDENT>allowed = [verb for verb in targets if verb != '<STR_LIT>']<EOL>if '<STR_LIT:GET>' in allowed and '<STR_LIT>' not in allowed:<EOL><INDENT>allowed.append('<STR_LIT>')<EOL><DEDENT>raise HTTPError(<NUM_LIT>, "<STR_LIT>",<EOL>header=[('<STR_LIT>',"<STR_LIT:U+002C>".join(allowed))])<EOL>
Return a (target, url_agrs) tuple or raise HTTPError(400/404/405).