import gzip


def gz_open(fname, omode):
    """
    Use :py:mod:`gzip` library to open compressed files ending with .gz.

    Parameters
    ----------
    fname : str
        Path to file to open.
    omode : str
        String indicating how the file is to be opened.

    Returns
    -------
    file
        File Object.

    """
    if fname.endswith(".gz"):
        return gzip.open(fname, omode)
    return open(fname, omode)