opatio.base.header module

class opatio.base.header.Header(version: int, numCards: int, headerSize: int, catalogOffset: int, creationDate: str, sourceInfo: str, comment: str, numIndex: int, hashPrecision: int, reserved: bytes = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00', magic: str = 'OPAT')[source]

Bases: OPATEntity

A class to represent the header information of an OPAT file.

version

Version of the OPAT file format.

Type:

int

numCards

Number of tables in the file.

Type:

int

headerSize

Size of the header in bytes.

Type:

int

catalogOffset

Offset to the index section.

Type:

int

creationDate

Creation date of the file.

Type:

str

sourceInfo

Source information of the file.

Type:

str

comment

Comment section of the file.

Type:

str

numIndex

Number of values to use when indexing the table.

Type:

int

hashPrecision

Precision of the hash.

Type:

int

reserved

Reserved for future use (default is 23 null bytes).

Type:

bytes

magic

Magic number to identify the file format (default is “OPAT”).

Type:

str

set_comment(comment: str)[source]

Sets the comment of the header.

set_source(source: str)[source]

Sets the source information of the header.

__bytes__()[source]

Converts the header to bytes.

__repr__()[source]

Returns the string representation of the header.

catalogOffset: int
comment: str
creationDate: str
hashPrecision: int
headerSize: int
magic: str = 'OPAT'
numCards: int
numIndex: int
reserved: bytes = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
set_comment(comment: str)[source]

Sets the comment of the header.

Parameters:

comment (str) – The comment to set.

Raises:

ValueError – If the comment string exceeds 128 characters.

Examples

>>> header = Header(...)
>>> header.set_comment("This is a comment.")
set_source(source: str)[source]

Sets the source information of the header.

Parameters:

source (str) – The source information to set.

Raises:

ValueError – If the source string exceeds 64 characters.

Examples

>>> header = Header(...)
>>> header.set_source("Source information")
sourceInfo: str
version: int
opatio.base.header.make_default_header() Header[source]

Creates a default header for an OPAT file.

Returns:

The default header.

Return type:

Header

Examples

>>> default_header = make_default_header()
>>> print(default_header)