class documentation

Base class for all var entries

A var file is made of one or more entries, each of which contain the data of the familiar var types.

Even though most var files have just one entry, an entry does NOT constitute a complete var file. All var files require an attached header and other metadata.

Use TIEntry.export to create a new TIVar containing the entry, with an optional custom header. Use TIEntry.save to export and save the entry in a var file in the current directory.

Class Raw Raw bytes container for TIEntry
Class Method get Converts bytes -> TIEntry
Class Method get_type Gets the subclass corresponding to a type ID if one is registered
Class Method open Creates a new entry from a file given a filename
Class Method register Registers a subtype with this class for coercion
Class Method set Converts TIEntry -> bytes
Static Method next_entry_length Helper function to determine the length of the next entry in a bytestream
Method __bool__ No summary
Method __bytes__ No summary
Method __copy__ No summary
Method __eq__ Determines if two entries are the same type and have the same bytes
Method __format__ Formats this entry for string representations
Method __init__ Creates an empty entry with specified meta and data values
Method __iter__ No summary
Method __len__ No summary
Method __str__ No summary
Method archive Archives this entry (if supported)
Method archived Whether the entry is archived
Method bytes The bytes contained in this entry, without any var file header or metadata.
Method calc_data The data section of the entry which is loaded on-calc
Method clear Clears this entry's data
Method coerce Coerces this entry to a subclass if possible using the entry's type ID
Method data The entry's user data
Method dict No summary
Method export Exports this entry to a TIVar with a specified name, header, and target model
Method get_min_os Determines the minimum OS that supports this entry's data
Method get_version Determines the version byte corresponding to given data for this entry type
Method load_bytes Loads a byte string or bytestream into this entry
Method load_data_section Loads the data of this entry from a bytestream
Method load_dict Loads this entry from a JSON dictionary representation
Method load_from_file Loads this entry from a file given a file pointer and offset
Method load_string Loads this entry from a string representation
Method meta_length The length of the meta section of the entry
Method name The name of the entry
Method save Saves this entry as a var file in the current directory given a filename and optional header and targeted model
Method string No summary
Method supported_by Determines whether a given model can support this entry
Method type_id The type ID of the entry
Method unarchive Unarchives this entry (if supported)
Method version The version number of the entry
Class Variable base_meta_length Undocumented
Class Variable extensions The file extension used for this entry per-model
Class Variable flash_meta_length Undocumented
Class Variable flash_only Whether this entry only supports flash chips
Class Variable leading_data_bytes Bytes that always begin this entry's data
Class Variable leading_name_byte Byte that always begins the name of this entry
Class Variable min_data_length The minimum length of this entry's data
Class Variable versions The possible versions of this entry
Instance Variable raw Undocumented
Property calc_data_length The length of the data section of the entry
Property flash_bytes The flash bytes of this entry if they exist
Property is_empty Whether this entry's data is empty
Property meta The meta section of this entry
Method __init_subclass__ Undocumented
Constant _T Undocumented
Class Variable _type_id Undocumented
Class Variable _type_ids Undocumented

Inherited from Dock:

Method load Loads data into an instance by delegating to Loader methods based on the input's type
Class Variable loaders Undocumented
@classmethod
def get(cls, data: bytes, **kwargs) -> _T: (source)

Converts bytes -> TIEntry

Parameters
data:bytesThe raw bytes to convert
**kwargsUndocumented
Returns
_TA TIEntry instance with data equal to data
@classmethod
def get_type(cls, type_id: int) -> type[TIEntry] | None: (source)

Gets the subclass corresponding to a type ID if one is registered

Parameters
type_id:intThe type ID to search by
Returns
type[TIEntry] | NoneA subclass of TIEntry with corresponding type ID or None
@classmethod
def open(cls, filename: str) -> Self: (source)

Creates a new entry from a file given a filename

Parameters
filename:strA filename to open
Returns
SelfThe (first) entry stored in the file
@classmethod
def register(cls, var_type: type[TIEntry], override: int = None): (source)

Registers a subtype with this class for coercion

Parameters
var_type:type[TIEntry]The TIEntry subtype to register
override:intA type ID to use for registry that differs from that of the var type
@classmethod
def set(cls, value: _T, **kwargs) -> bytes: (source)

Converts TIEntry -> bytes

Parameters
value:_TThe value to convert
**kwargsUndocumented
Returns
bytesThe data of value
@staticmethod
def next_entry_length(stream: BinaryIO) -> int: (source)

Helper function to determine the length of the next entry in a bytestream

Parameters
stream:BinaryIOA bytestream
Returns
intThe length of the next entry in the bytestream
def __bool__(self) -> bool: (source)
Returns
boolWhether this entry's data is empty
def __bytes__(self) -> bytes: (source)
Returns
bytesThe bytes contained in this entry
def __copy__(self) -> Self: (source)
Returns
SelfA copy of this entry
def __eq__(self, other: TIEntry) -> bool: (source)

Determines if two entries are the same type and have the same bytes

Parameters
other:TIEntryThe entry to check against
Returns
boolWhether this entry is equal to other
def __format__(self, format_spec: str) -> str: (source)

Formats this entry for string representations

Parameters
format_spec:strThe format parameters
Returns
strA string representation of this entry
def __init__(self, init=None, *, for_flash: bool = True, name: str = 'UNNAMED', version: int = None, archived: bool = None, data: bytes = None): (source)

Creates an empty entry with specified meta and data values

The entry version and archived flag are invalid if for_flash == False.

Parameters
initValues to initialize the entry's data (defaults to None)
for_flash:boolWhether the entry supports flash chips (defaults to True)
name:strThe name of the entry (defaults to a valid default name)
version:intThe entry's version (defaults to None)
archived:boolWhether the entry is archived (defaults to entry's default state on-calc)
data:bytesThe entry's data (defaults to empty)
def __iter__(self) -> Iterator: (source)
Returns
IteratorIf this entry is a container or collection, an iterator over its elements
def __len__(self) -> int: (source)
Returns
intThe total length of this entry's bytes
def __str__(self) -> str: (source)
Returns
strA string representation of this entry
def archive(self): (source)

Archives this entry (if supported)

@Section(1, Boolean)
def archived(self, value) -> bool: (source)

Whether the entry is archived

Only flash files support this entry, and it thus not present if meta_length <= 11.

def bytes(self) -> bytes: (source)

The bytes contained in this entry, without any var file header or metadata.

These bytes do NOT constitute a complete var file. Use .export and .save to save a var file.

Returns
bytesThe bytes contained in this entry
def coerce(self): (source)

Coerces this entry to a subclass if possible using the entry's type ID

Valid types must be registered to be considered for coercion.

def export(self, *, name: str = None, header: TIHeader = None, model: TIModel = None) -> TIVar: (source)

Exports this entry to a TIVar with a specified name, header, and target model

Parameters
name:strThe name of the var (defaults to this entry's name)
header:TIHeaderA TIHeader to attach (defaults to an empty header)
model:TIModelA TIModel to target (defaults to None)
Returns
TIVarUndocumented
def get_min_os(self, data: bytes = None) -> OsVersion: (source)

Determines the minimum OS that supports this entry's data

Parameters
data:bytesThe data to find the minimum support for (defaults to this entry's data)
Returns
OsVersionThe minimum OsVersion this entry supports
def get_version(self, data: bytes = None) -> int: (source)

Determines the version byte corresponding to given data for this entry type

Entries which could contain non-backwards compatible data are assigned a version byte. If an entry's version exceeds the "version" of a calculator, transfer to the calculator will fail.

Parameters
data:bytesThe data to find the version of (defaults to this entry's data)
Returns
intThe version byte for data
@Loader[bytes, bytearray, BytesIO]
def load_bytes(self, data: bytes | BytesIO): (source)

Loads a byte string or bytestream into this entry

Parameters
data:bytes | BytesIOThe bytes to load
def load_data_section(self, data: BytesIO): (source)

Loads the data of this entry from a bytestream

Parameters
data:BytesIOThe source bytes
@Loader[dict]
def load_dict(self, dct: dict): (source)

Loads this entry from a JSON dictionary representation

Parameters
dct:dictThe dict to load
@Loader[BinaryIO]
def load_from_file(self, file: BinaryIO, *, offset: int = 0): (source)

Loads this entry from a file given a file pointer and offset

Parameters
file:BinaryIOA binary file to read from
offset:intThe offset of the entry to read
@Section(2, Integer)
def meta_length(self, value) -> int: (source)

The length of the meta section of the entry

The possible meta lengths are 11 (without flash) or 13 (with flash).

def save(self, filename: str = None, *, header: TIHeader = None, model: TIModel = None): (source)

Saves this entry as a var file in the current directory given a filename and optional header and targeted model

Parameters
filename:strA filename to save to (defaults to the var's name and extension)
header:TIHeaderA TIHeader to attach (defaults to an empty header)
model:TIModelA TIModel to target (defaults to None)
def supported_by(self, model: TIModel) -> bool: (source)

Determines whether a given model can support this entry

Parameters
model:TIModelThe model to check support for
Returns
boolWhether model supports this entry
@Section(1, Bits[:])
def type_id(self) -> int: (source)

The type ID of the entry

The type determines how the contents of the data section of the entry are interpreted.

def unarchive(self): (source)

Unarchives this entry (if supported)

@Section(1, Bits[:])
def version(self, value) -> int: (source)

The version number of the entry

The version is used to determine model compatibility where necessary. Only flash files support this entry, and it thus not present if meta_length <= 11.

base_meta_length: int = (source)

Undocumented

flash_meta_length: int = (source)

Undocumented

leading_data_bytes: bytes = (source)

Bytes that always begin this entry's data

min_data_length: int = (source)

The minimum length of this entry's data

If an entry's data is fixed in size, this value is necessarily the length of the data

Undocumented

@property
calc_data_length: int = (source)

The length of the data section of the entry

The flash bytes of this entry if they exist

Whether this entry's data is empty

The meta section of this entry

def __init_subclass__(cls, /, register=False, override=None, **kwargs): (source)

Undocumented

Undocumented

Value
'TIEntry'
_type_ids: dict = (source)

Undocumented