def file_strip_ext(<EOL>afile,<EOL>skip_version=False,<EOL>only_known_extensions=False,<EOL>allow_subformat=True):
import os<EOL>afile = afile.split('<STR_LIT:;>')<EOL>if len(afile) > <NUM_LIT:1> and allow_subformat and not afile[-<NUM_LIT:1>].isdigit():<EOL><INDENT>afile = afile[<NUM_LIT:0>:-<NUM_LIT:1>]<EOL><DEDENT>if len(afile) > <NUM_LIT:1> and skip_version and afile[-<NUM_LIT:1>].isdigit():<EOL><INDENT>afile = afile[<NUM_LIT:0>:-<NUM_LIT:1>]<EOL><DEDENT>afile = '<STR_LIT:;>'.join(afile)<EOL>nextfile = _extensions.sub('<STR_LIT>', afile)<EOL>if nextfile == afile and not only_known_extensions:<EOL><INDENT>nextfile = os.path.splitext(afile)[<NUM_LIT:0>]<EOL><DEDENT>while nextfile != afile:<EOL><INDENT>afile = nextfile<EOL>nextfile = _extensions.sub('<STR_LIT>', afile)<EOL><DEDENT>return nextfile<EOL>
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