import pathlib


def file_get_extension(filepath,
                       with_extension_dot=False,
                       only_last_extension=False):
    """returns the extension of a file by a provided filepath\n
    with_extension_dot (default: False): True, will include the dot e.g. '.txt'\n
    only_last_extension (default: False): True, returns only the last extension e.g. 'gz' instead of 'tar.gz'
    """

    if only_last_extension:
        return pathlib.Path(filepath).suffix[(0 if with_extension_dot else 1):]
    else:
        return "".join(
            pathlib.Path(filepath).suffixes)[(0 if with_extension_dot else 1):]