hdmf.backends.io module¶
- class hdmf.backends.io.HDMFIO(manager=None, source=None)¶
Bases:
object
- Parameters
manager (
BuildManager
) – the BuildManager to use for I/Osource (
str
orPath
) – the source of container being built i.e. file path
- property manager¶
The BuildManager this instance is using
- property 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
- 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)
- NOTE: When implementing export support on custom backends. Export does not update the Builder.source
on the Builders. As such, when writing LinkBuilders we need to determine if LinkBuilder.source and LinkBuilder.builder.source are the same, and if so the link should be internal to the current file (even if the Builder.source points to a different location).
- 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 exportedwrite_args (
dict
) – arguments to pass towrite_builder
- abstract read_builder()¶
Read data and return the GroupBuilder representing it
- Returns
a GroupBuilder representing the read data
- Return type
- abstract write_builder(builder)¶
Write a GroupBuilder representing an Container object
- Parameters
builder (
GroupBuilder
) – the GroupBuilder object representing the Container
- abstract open()¶
Open this HDMFIO object for writing of the builder
- abstract close()¶
Close this HDMFIO object to further reading/writing