def open(path, broken=False):
    """
    Context manager for opening and reading json lines files.
    If file extension suggests gzip (.gz or .gzip), file is
    decompressed on fly.

    Pass broken=True if you expect the file can be truncated
    or broken otherwise; reader will try to recover as much data
    as possible in this case.
    """
    with maybe_gzip_open(path) as f:
        yield reader(f, broken=broken)