docs: def file_strip_ext(
          afile,
          skip_version=False,
          only_known_extensions=False,
          allow_subformat=True):
      """
      Strip in the best way the extension from a filename.
  
      >>> file_strip_ext("foo.tar.gz")
      'foo'
      >>> file_strip_ext("foo.buz.gz")
      'foo.buz'
      >>> file_strip_ext("foo.buz")
      'foo'
      >>> file_strip_ext("foo.buz", only_known_extensions=True)
      'foo.buz'
      >>> file_strip_ext("foo.buz;1", skip_version=False,
      ... only_known_extensions=True)
      'foo.buz;1'
      >>> file_strip_ext("foo.gif;icon")
      'foo'
      >>> file_strip_ext("foo.gif;icon", only_know_extensions=True,
      ... allow_subformat=False)
      'foo.gif;icon'
  
      @param afile: the path/name of a file.
      @type afile: string
      @param skip_version: whether to skip a trailing ";version".
      @type skip_version: bool
      @param only_known_extensions: whether to strip out only known extensions or
          to consider as extension anything that follows a dot.
      @type only_known_extensions: bool
      @param allow_subformat: whether to consider also subformats as part of
          the extension.
      @type allow_subformat: bool
      @return: the name/path without the extension (and version).
      @rtype: string
      """
      import os
      afile = afile.split(';')
      if len(afile) > 1 and allow_subformat and not afile[-1].isdigit():
          afile = afile[0:-1]
      if len(afile) > 1 and skip_version and afile[-1].isdigit():
          afile = afile[0:-1]
      afile = ';'.join(afile)
      nextfile = _extensions.sub('', afile)
      if nextfile == afile and not only_known_extensions:
          nextfile = os.path.splitext(afile)[0]
      while nextfile != afile:
          afile = nextfile
          nextfile = _extensions.sub('', afile)
      return nextfile