def read_from_filenode(h5file, filename, where, name=None, overwrite=False,
                       create_target=False):
    new_h5file = not isinstance(h5file, tables.file.File)
    f = tables.File(h5file, "r") if new_h5file else h5file
    try:
        fnode = open_node(f.get_node(where=where, name=name))
    except tables.NoSuchNodeError:
        fnode = None
        for n in f.walk_nodes(where=where, classname="EArray"):
            if n.attrs._filename == name:
                fnode = open_node(n)
                break
        if fnode is None:
            f.close()
            raise tables.NoSuchNodeError("A filenode '%s' cannot be found at "
                                         "'%s'" % (name, where))

    # guess output filename if necessary
    if os.path.isdir(filename) or filename.endswith(os.path.sep):
        try:
            filename = os.path.join(filename, fnode.node.attrs._filename)
        except Exception:
            filename = os.path.join(filename, fnode.node.name)

    if os.access(filename, os.R_OK) and not overwrite:
        if new_h5file:
            f.close()
        raise IOError("The file '%s' already exists" % filename)

    # create folder hierarchy if necessary
    if create_target and not os.path.isdir(os.path.split(filename)[0]):
        os.makedirs(os.path.split(filename)[0])

    if not os.access(os.path.split(filename)[0], os.W_OK):
        if new_h5file:
            f.close()
        raise IOError("The file '%s' cannot be written to" % filename)

    # read data from filenode
    data = fnode.read()
    fnode.close()

    # store data to file
    with open(filename, "wb") as fd:
        fd.write(data)

    # cleanup
    del data
    if new_h5file:
        f.close()


## Local Variables:
## mode: python
## py-indent-offset: 4
## tab-width: 4
## End:
Hook for specifying the form Field instance for a given database Field
dataset/ETHPy150Open PyTables/PyTables/tables/nodes/filenode.py/read_from_filenode--crossover with--dataset/ETHPy150Open fusionbox/django-widgy/widgy/models/base.py/Content.formfield_for_dbfield