docs: def explode_filename(name: str, scheme: str) -> dict:
      """
      Removes any path components from the input filename and returns a
      dictionary containing the name of the file without extension and the
      extension (if an extension exists)
  
      :param name:
      :param scheme:
      :return:
      """
  
      if not scheme:
          return split_filename(name)
  
      replacements = {
          'name': '(?P<name>.*)',
          'ext': '(?P<extension>.+)$',
          'index': '(?P<index>[0-9]{{{length}}})'
      }
  
      scheme_pattern = '^'
      empty_scheme_pattern = ''
  
      offset = 0
      while offset < len(scheme):
          char = scheme[offset]
          next_char = scheme[offset + 1] if (offset + 1) < len(scheme) else None
  
          if char in r'.()^$?*+\[]|':
              addition = '\\{}'.format(char)
              scheme_pattern += addition
              empty_scheme_pattern += addition
              offset += 1
              continue
  
          if char != '{':
              scheme_pattern += char
              empty_scheme_pattern += char
              offset += 1
              continue
  
          if next_char != '{':
              scheme_pattern += char
              empty_scheme_pattern += char
              offset += 1
              continue
  
          end_index = scheme.find('}}', offset)
  
          contents = scheme[offset:end_index].strip('{}').lower()
  
          if contents in replacements:
              scheme_pattern += replacements[contents]
          elif contents == ('#' * len(contents)):
              addition = replacements['index'].format(length=len(contents))
              scheme_pattern += addition
              empty_scheme_pattern += addition
          else:
              addition = '{{{}}}'.format(contents)
              scheme_pattern += addition
              empty_scheme_pattern += addition
  
          offset = end_index + 2
  
      match = re.compile(scheme_pattern).match(name)
  
      if not match:
          parts = split_filename(name)
          comparison = re.compile(empty_scheme_pattern.rstrip('-_: .\\'))
          match = comparison.match(parts['name'])
          if not match:
              return parts
  
      parts = match.groupdict()
      index = parts.get('index')
      index = int(index) if index else None
  
      return dict(
          index=index - 1,
          name=parts.get('name', ''),
          extension=parts.get('extension', 'py')
      )