コード例 #1
0
ファイル: json_py.py プロジェクト: raamana/datalad
def dump2stream(obj, fname, compressed=False):

    _open = LZMAFile if compressed else open

    with _open(fname, mode='wb') as f:
        jwriter = codecs.getwriter('utf-8')(f)
        for o in obj:
            jsondump(o, jwriter, **compressed_json_dump_kwargs)
            f.write(b'\n')
コード例 #2
0
def dump2stream(obj, fname, compressed=False):

    _open = LZMAFile if compressed else open

    indir = dirname(fname)

    if op.lexists(fname):
        os.remove(fname)
    elif indir and not exists(indir):
        makedirs(indir)
    with _open(fname, mode='wb') as f:
        jwriter = codecs.getwriter('utf-8')(f)
        for o in obj:
            jsondump(o, jwriter, **compressed_json_dump_kwargs)
            f.write(b'\n')
コード例 #3
0
ファイル: json_py.py プロジェクト: datalad/datalad
def dump2stream(obj, fname, compressed=False):

    _open = LZMAFile if compressed else open

    indir = dirname(fname)

    if op.lexists(fname):
        os.remove(fname)
    elif indir and not exists(indir):
        makedirs(indir)
    with _open(fname, mode='wb') as f:
        jwriter = codecs.getwriter('utf-8')(f)
        for o in obj:
            jsondump(o, jwriter, **compressed_json_dump_kwargs)
            f.write(b'\n')
コード例 #4
0
ファイル: json_py.py プロジェクト: leej3/datalad
def dump2fileobj(obj, fileobj, **kwargs):
    """Dump a JSON-serializable objects into a file-like

    Parameters
    ----------
    obj : object
      Structure to serialize.
    fileobj : file
      Writeable file-like object to dump into.
    **kwargs
      Keyword arguments to be passed on to simplejson.dump()
    """
    return jsondump(obj, codecs.getwriter('utf-8')(fileobj), **kwargs)
コード例 #5
0
ファイル: json_py.py プロジェクト: datalad/datalad
def dump2fileobj(obj, fileobj, **kwargs):
    """Dump a JSON-serializable objects into a file-like

    Parameters
    ----------
    obj : object
      Structure to serialize.
    fileobj : file
      Writeable file-like object to dump into.
    **kwargs
      Keyword arguments to be passed on to simplejson.dump()
    """
    return jsondump(
        obj,
        codecs.getwriter('utf-8')(fileobj),
        **kwargs)
コード例 #6
0
def dump2fileobj(obj, fileobj):
    return jsondump(obj,
                    codecs.getwriter('utf-8')(fileobj), **json_dump_kwargs)
コード例 #7
0
def dump2xzstream(obj, fname):
    with LZMAFile(fname, mode='w') as f:
        jwriter = codecs.getwriter('utf-8')(f)
        for o in obj:
            jsondump(o, jwriter, **compressed_json_dump_kwargs)
            f.write(b'\n')
コード例 #8
0
ファイル: json_py.py プロジェクト: hanke/datalad
def dump2fileobj(obj, fileobj):
    return jsondump(
        obj,
        codecs.getwriter('utf-8')(fileobj),
        **json_dump_kwargs)
コード例 #9
0
ファイル: json_py.py プロジェクト: yarikoptic/datalad
def dump(obj, fname):
    with open(fname, 'wb') as f:
        return jsondump(
            obj,
            codecs.getwriter('utf-8')(f),
            **json_dump_kwargs)