@resource.register('.*\.json(\.gz)?')
def resource_json_ambiguous(path, **kwargs):
    """ Try to guess if this file is line-delimited or not """
    if os.path.exists(path):
        f = open(path)
        try:
            one = next(f)
        except __HOLE__:  # gzip
            f.close()
            return resource_json(path, **kwargs)
        try:
            next(f)
        except StopIteration:  # only one line
            f.close()
            return resource_json(path, **kwargs)
        try:
            json.loads(one)
            return resource_jsonlines(path, **kwargs)
        except:
            return resource_json(path, **kwargs)
        finally:
            f.close()

    # File doesn't exist, is the dshape variable length?
    dshape = kwargs.get('expected_dshape', None)
    if dshape and dshape[0] == var:
        return resource_jsonlines(path, **kwargs)
    else:
        return resource_json(path, **kwargs)
dataset/ETHPy150Open blaze/odo/odo/backends/json.py/resource_json_ambiguous