Skip to content

Consistent multi-object handling #176

@toddrjen

Description

@toddrjen

Currently users need to know a lot about the specifics of their IO class to read it properly. One of the biggest problems is that, without reading the documentation, the users can't tell whether their IO class should support one or more base objects. All IO classes support the read method. However, in IO classes that have, for example, multiple Block objects, there is no external indication that is possible. There is currently no way that someone can write code that will read all data from any IO class, they have to check whether it can contain multiple objects or not.

So I suggest adding a more consistent interface to deal with this. Specifically in BaseIO, implement a read_all method, which is the multi-object version of read. By default, this will just return [self.read()], but IO classes that support multiple objects can override it. Similarly, there should be read_all_* methods for each read_* method, which again by default are just [self.read_*()] (which would fall through to an AssertionError for classes that don't support that object).

With this approach, a user can just call read_all(), and they will always get all the data from the file, no matter how it is implemented.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions