

def __template_to_regex(self, template):
    var_regex = re.compile('\n            \\{          # The exact character "{"\n            (\\w+)       # The variable name (restricted to a-z, 0-9, _)\n            (?::([^}]+))? # The optional :regex part\n            \\}          # The exact character "}"\n           ', re.VERBOSE)
    regex = ''
    last_pos = 0
    for match in var_regex.finditer(template):
        regex += re.escape(template[last_pos:match.start()])
        var_name = match.group(1)
        expr = (match.group(2) or '[^/]+')
        expr = ('(?P<%s>%s)' % (var_name, expr))
        regex += expr
        last_pos = match.end()
    regex += re.escape(var_regex[last_pos:])
    regex = ('^%s$' % regex)
    return re.compile(regex)

dataset/ETHPy150Open galaxyproject/pulsar/pulsar/web/framework.py RoutingApp.__template_to_regex/VarMisuse@116/228 `template`->`var_regex`