File object which can be passed to adaptors.

We use this since multiple file adaptors may need to open/read the file while dispatch is determining which adaptor to use, and the FileHandle allows us to keep any results from previous reads.

class str, is_hdf5: bool = False, is_json: Optional[bool] = None, is_open: bool = False, file: object = None, text: Optional[str] = None, json: object = None)[source]

Reference to a file; can hold loaded data so it needn’t be read twice.


Closes the file.

property file

The raw file object.

property format_id

Returns an ID from the metadata we store in some HDF5 or JSON formats.

This can be used if we need to distinguish multiple formats with a common underlying file type, e.g., HDF5-based file formats. See LabelsV1Adaptor for an example (the format id is here used to determine whether to convert from “gridline” to “midpixel” coordinates).

property is_hdf5

Whether file is HDF5.

property is_json

Whether file is JSON.

property json

The loaded JSON dictionary (for a JSON file).


Opens the file (if it’s not already open).

property text

The text from a text file.