class documentation

Container for var files

A var file is composed of a header and any number of entries (though most have only one).

Class Method open Creates a new var from a file given a filename
Method __bool__ No summary
Method __bytes__ No summary
Method __copy__ No summary
Method __eq__ Determines if two vars contain the same entries
Method __init__ Creates an empty var with a specified name, header, and targeted model
Method __len__ No summary
Method add_entry Adds an entry to this var
Method bytes No summary
Method clear Removes all entries from this var
Method load_bytes Loads a byte string or bytestream into this var
Method load_var_file Loads this var from a file given a file pointer
Method save Saves this var given a filename
Method supported_by Determines whether a given model can support this var
Instance Variable entries Undocumented
Instance Variable name Undocumented
Property checksum The checksum for the var
Property entry_length The total length of the var entries
Property extension Determines the var's file extension based on its entries and targeted model
Property filename Determines the var's filename based on its name, entries, and targeted model
Property header This var's header
Property is_empty Whether this var contains no entries
Property model This var's targeted model
Instance Variable _header Undocumented
Instance Variable _model Undocumented
@classmethod
def open(cls, filename: str) -> TIVar: (source)

Creates a new var from a file given a filename

Parameters
filename:strA filename to open
Returns
TIVarThe var stored in the file
def __bool__(self) -> bool: (source)
Returns
boolWhether this var contains no entries
def __bytes__(self) -> bytes: (source)
Returns
bytesThe bytes contained in this var
def __copy__(self) -> TIVar: (source)
Returns
TIVarA copy of this var
def __eq__(self, other: TIVar): (source)

Determines if two vars contain the same entries

Parameters
other:TIVarThe var to check against
Returns
Whether this var is equal to other
def __init__(self, *, name: str = 'UNNAMED', header: TIHeader = None, model: TIModel = None, data: bytes = None): (source)

Creates an empty var with a specified name, header, and targeted model

Parameters
name:strThe name of the var (defaults to UNNAMED)
header:TIHeaderA TIHeader to attach (defaults to an empty header)
model:TIModelA minimum TIModel to target (defaults to None)
data:bytesThe var's data (defaults to empty)
def __len__(self): (source)
Returns
The total length of this var's bytes
def add_entry(self, entry: TIEntry = None): (source)

Adds an entry to this var

Parameters
entry:TIEntryA TIEntry to add (defaults to an empty entry)
def bytes(self): (source)
Returns
The bytes contained in this var
def clear(self): (source)

Removes all entries from this var

def load_bytes(self, data: bytes | BytesIO): (source)

Loads a byte string or bytestream into this var

Parameters
data:bytes | BytesIOThe bytes to load
def load_var_file(self, file: BinaryIO): (source)

Loads this var from a file given a file pointer

Parameters
file:BinaryIOA binary file to read from
def save(self, filename: str = None): (source)

Saves this var given a filename

Parameters
filename:strA filename to save to (defaults to the var's name and extension)
def supported_by(self, model: TIModel = None) -> bool: (source)

Determines whether a given model can support this var

Parameters
model:TIModelThe model to check support for (defaults to this var's model, if it is set)
Returns
boolWhether model supports this var

Undocumented

Undocumented

The checksum for the var

This is equal to the lower 2 bytes of the sum of all bytes in the entries.

@property
entry_length: int = (source)

The total length of the var entries

This should always be 57 less than the total var size.

Determines the var's file extension based on its entries and targeted model

If there is only one entry, that entry's extension for the target model is used. Otherwise, .8xg is used.

Determines the var's filename based on its name, entries, and targeted model

The filename is the concatenation of the var name and extension (see TIVar.extension).

This var's header

Whether this var contains no entries

This var's targeted model

Undocumented

Undocumented