Ejemplo n.º 1
0
def test_dump2stream(path):
    stream = [dict(a=5), dict(b=4)]
    dump2stream([dict(a=5), dict(b=4)], path)
    eq_(list(load_stream(path)), stream)

    # the same for compression
    dump2xzstream([dict(a=5), dict(b=4)], path)
    eq_(list(load_xzstream(path)), stream)
Ejemplo n.º 2
0
def _load_xz_json_stream(fpath, cache=None):
    if cache is None:
        cache = {}
    obj = cache.get(
        fpath,
        {s['path']: {k: v for k, v in s.items() if k != 'path'}
         # take out the 'path' from the payload
         for s in load_xzstream(fpath)} if lexists(fpath) else {})
    cache[fpath] = obj
    return obj
Ejemplo n.º 3
0
def _load_xz_json_stream(fpath, cache=None):
    if cache is None:
        cache = {}
    obj = cache.get(
        fpath,
        {s['path']: {k: v for k, v in iteritems(s) if k != 'path'}
         # take out the 'path' from the payload
         for s in load_xzstream(fpath)} if op.lexists(fpath) else {})
    cache[fpath] = obj
    return obj