pyrocko.file¶
IO library for simple binary files.
Classes
|
Record-based binary file container, used by the YAFF and RUG formats. |
- class File(f, type_label='TEST', version='0000', record_formats={}, optional_entries={})[source]¶
Bases:
objectRecord-based binary file container, used by the YAFF and RUG formats.
A file is a sequence of records, each with a header (file type label, version, sizes, optional SHA1 hash and record type) and a payload of named, typed entries. The entries of each record type are declared in
record_formats.- Parameters:
f – Open file object, in binary mode.
type_label (str) – File type label, four characters.
version (str) – File format version, four characters.
record_formats (dict) – Entries of each record type, as
{record_type: {key: type}}.optional_entries (dict) – Entries which may be missing, as
{record_type: set of keys}. Missing optional entries are read asNone, and entries with valueNoneare not written.