def __template_to_regex(self, template):
        var_regex = re.compile(r'''
            \{          # The exact character "{"
            (\w+)       # The variable name (restricted to a-z, 0-9, _)
            (?::([^}]+))? # The optional :regex part
            \}          # The exact character "}"
           ''', 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(template[last_pos:])
        regex = '^%s$' % regex
        return re.compile(regex)
dataset/ETHPy150Open galaxyproject/pulsar/pulsar/web/framework.py/RoutingApp.__template_to_regex/original