from pathlib import Path
from typing import TextIO
import gzip


def tsv_opener(path: Path) -> TextIO:
    """
    Open a TSV (either text file or gzip-compressed text file).

    Args:
      path : The path to the TSV file.
    """
    if path.suffix == ".gz":
        fh = gzip.open(path, "rt")
    else:
        fh = open(path, "r")
    return fh