from pathlib import Path


def stem(fname, include_suffix=False):
    """/blah/my_file.json.gz --> my_file"""
    path = Path(fname)
    stem = path.stem

    # If a filename has multiple suffixes, take them all off.
    stem = stem[: stem.index(".")] if "." in stem else stem

    if include_suffix:
        stem = stem + "".join(path.suffixes)

    return stem