def rm_gz_suffix(path):
    """Gzip aware suffix removal

    If .gz is the final path extension then two extensions are removed.
    """
    if path.suffix == ".gz":
        num_suffixes_to_remove = 2
    else:
        num_suffixes_to_remove = 1
    return path.with_suffix("", num_suffixes_to_remove)