import gzip


def opengz(filename, mode):
    """Return either the system open or the gzip open """
    if filename.endswith('.gz'):
        return gzip.open(filename, mode)
    else:
        return open(filename, mode)