hdmf.backends.io module

class hdmf.backends.io.HDMFIO(manager=None, source=None)

Bases: object

Parameters:
  • manager (BuildManager) – the BuildManager to use for I/O
  • source (str) – the source of container being built i.e. file path
manager

The BuildManager this instance is using

source

The source of the container being read/written i.e. file path

read()

Read a container from the IO source.

Returns:the Container object that was read in
Return type:Container
write(container)

Write a container to the IO source.

Parameters:container (Container) – the Container object to write
export(src_io, container=None, write_args={})

Export from one backend to the backend represented by this class.

If container is provided, then the build manager of src_io is used to build the container, and the resulting builder will be exported to the new backend. So if container is provided, src_io must have a non-None manager property. If container is None, then the contents of src_io will be read and exported to the new backend.

The provided container must be the root of the hierarchy of the source used to read the container (i.e., you cannot read a file and export a part of that file.

Arguments can be passed in for the write_builder method using write_args. Some arguments may not be supported during export.

Example usage:

old_io = HDF5IO('old.nwb', 'r')
with HDF5IO('new_copy.nwb', 'w') as new_io:
    new_io.export(old_io)
Parameters:
  • src_io (HDMFIO) – the HDMFIO object for reading the data to export
  • container (Container) – the Container object to export. If None, then the entire contents of the HDMFIO object will be exported
  • write_args (dict) – arguments to pass to write_builder
read_builder()

Read data and return the GroupBuilder representing it

Returns:a GroupBuilder representing the read data
Return type:GroupBuilder
write_builder(builder)

Write a GroupBuilder representing an Container object

Parameters:builder (GroupBuilder) – the GroupBuilder object representing the Container
open()

Open this HDMFIO object for writing of the builder

close()

Close this HDMFIO object to further reading/writing

exception hdmf.backends.io.UnsupportedOperation

Bases: ValueError