apptools.io.h5.dict_node module

apptools.io.h5.dict_node.ARRAY_PROXY_KEY = '__array__'

The key name which identifies array objects in the JSON dict.

class apptools.io.h5.dict_node.H5DictNode(h5_group, auto_flush=True)[source]

Bases: object

Dictionary-like node interface.

Data for the dict is stored as a JSON file in a PyTables FileNode. This allows easy storage of Python objects, such as dictionaries and lists of different data types.

Note that this is implemented using a group-node assuming that arrays are valid inputs and will be stored as H5 array nodes.

Parameters
  • h5_group (H5Group instance) – Group node which will be used as a dictionary store.

  • auto_flush (bool) – If True, write data to disk whenever the dict data is altered. Otherwise, call flush() explicitly to write data to disk.

classmethod add_to_h5file(h5, node_path, data=None, **kwargs)[source]

Add dict node to an H5 file at the specified path.

Parameters
  • h5 (H5File) – The H5 file where the dictionary data will be stored.

  • node_path (str) – Path to node where data is stored (e.g. ‘/path/to/my_dict’)

  • data (dict) – Data for initialization, if desired.

property data
flush()[source]

Write buffered data to disk.

classmethod is_dict_node(pytables_node)[source]

Return True if PyTables node looks like an H5DictNode.

NOTE: That this returns False if the node is an H5DictNode instance, since the input node should be a normal PyTables Group node.

keys()[source]