def get_extension(filepath, check_if_exists=False):
if check_if_exists:<EOL><INDENT>if not os.path.exists(filepath):<EOL><INDENT>err = '<STR_LIT>' + filepath<EOL>log.error(err)<EOL>raise IOError(err)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>rest, ext = os.path.splitext(filepath)<EOL><DEDENT>except:<EOL><INDENT>raise<EOL><DEDENT>else:<EOL><INDENT>return ext<EOL><DEDENT>
Return the extension of fpath.

    Parameters
    ----------
    fpath: string
    File name or path

    check_if_exists: bool

    Returns
    -------
    str
    The extension of the file name or path