<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 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. 'foo' 'foo.buz' 'foo' 'foo.buz' 'foo.buz;1' 'foo' '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