Beispiel #1
0
def read_from_cache(cachename=None, cachedir=None, reread=False):
    if cachedir is None:
        cachedir = path.getcwd() / "_hfcache"
    else:
        cachedir = path(cachedir)
    cachename = cachedir / cachename + ".hdf5"
    return read_hdf5(cachename)
Beispiel #2
0
def read_from_cache(cachename=None, cachedir=None, reread=False):
    if cachedir is None:
        cachedir = path.getcwd() / "_hfcache"
    else:
        cachedir = path(cachedir)
    cachename = cachedir / cachename + ".hdf5"
    return read_hdf5(cachename)
Beispiel #3
0
def read_to_cache(filename, cachename=None, cachedir=None,
                  reread=False, verbose=True):
    if cachedir is None:
        cachedir = path.getcwd() / "_hfcache"
    else:
        cachedir = path(cachedir)
    filename = path(filename)
    cachedir.makedirs(silent=True)
    if cachename is None:
        namebase = filename.namebase
    else:
        namebase = cachename
    cachename = cachedir / namebase + ".hdf5"
    if not cachename.exists() or reread:
        data = read_data(filename, verbose=verbose)
        yield data, True
        save_hdf5(data, cachename)
    else:
        data = read_hdf5(cachename)
        yield data, False
Beispiel #4
0
def read_to_cache(filename,
                  cachename=None,
                  cachedir=None,
                  reread=False,
                  verbose=True):
    if cachedir is None:
        cachedir = path.getcwd() / "_hfcache"
    else:
        cachedir = path(cachedir)
    filename = path(filename)
    cachedir.makedirs(silent=True)
    if cachename is None:
        namebase = filename.namebase
    else:
        namebase = cachename
    cachename = cachedir / namebase + ".hdf5"
    if not cachename.exists() or reread:
        data = read_data(filename, verbose=verbose)
        yield data, True
        save_hdf5(data, cachename)
    else:
        data = read_hdf5(cachename)
        yield data, False