code: def parse(path):
      
      parsed = re.sre_parse.parse(path)
      for case, _ in parsed:
          if case not in (re.sre_parse.LITERAL, re.sre_parse.ANY):
              break
      else:
          return path
  
      path = path.strip('^$')
  
      def parse_(match):
          [part] = match.groups()
          match = DYNR_RE.match(part)
          params = match.groupdict()
          return '(?P<%s>%s)' % (params['var'], params['re'] or '[^{}/]+')
  
      return re.compile('^%s$' % DYNS_RE.sub(parse_, path))
docs: Parse URL path and convert it to regexp if needed.