docs: def get_pattern_formatter(cls, location):
          """
          Fragment from aiohttp.web_urldispatcher.UrlDispatcher#add_resource
          :param location:
          :return:
          """
          pattern = ''
          formatter = ''
          canon = ''
          for part in cls.ROUTE_RE.split(location):
              match = cls.DYN.match(part)
              if match:
                  pattern += '(?P<{}>{})'.format(match.group('var'), cls.GOOD)
                  formatter += '{' + match.group('var') + '}'
                  continue
  
              match = cls.DYN_WITH_RE.match(part)
              if match:
                  pattern += '(?P<{var}>{re})'.format(**match.groupdict())
                  formatter += '{' + match.group('var') + '}'
                  canon += match.group('re')
                  continue
  
              if '{' in part or '}' in part:
                  raise ValueError("Invalid path '{}'['{}']".format(
                      location, part))
  
              formatter += part
              pattern += re.escape(part)
              canon += part
  
          try:
              return re.compile(pattern), formatter, canon
          except re.error as exc:
              raise ValueError(
                  "Bad pattern '{}': {}".format(pattern, exc)) from None