class documentation

Base class for data components of TI files

The subclasses of TIComponent are TIEntry (for var files) and TIFlashHeader (for flash files). Note that TIHeader is not a TIComponent due to not having proper attached data.

Class Raw Raw bytes container for this component
Class Method get Converts bytes -> TIComponent
Class Method get_type Gets the subclass corresponding to a type ID, type name, or file extension if one is registered
Class Method open Creates a new component from a file given a filename
Class Method register Registers a subtype with this class for coercion
Class Method set Converts TIComponent -> bytes
Method __bool__ No summary
Method __bytes__ No summary
Method __copy__ No summary
Method __eq__ Determines if two components are the same type and have the same bytes
Method __format__ Undocumented
Method __init__ Creates an empty component with specified data
Method __len__ No summary
Method __str__ No summary
Method bytes No summary
Method calc_data The data section of the component which is loaded on-calc
Method clear Clears this component's data
Method coerce Coerces this component to a subclass if possible using the component's type ID
Method data The component's user data
Method dict No summary
Method get_extension Determines the file extension for a targeted model based on its contents
Method json No summary
Method load_bytes Loads a byte string or bytestream into this component
Method load_dict Loads this component from a JSON dictionary representation
Method load_from_file Loads this component from a file given a file pointer and offset
Method load_json Loads this component from a JSON dictionary representation
Method load_string Loads this component from a string representation
Method name The name of the component
Method save Saves this component as a complete file in the current directory given a filename and optional targeted model
Method string No summary
Method summary No summary
Method type_id The (first) type ID of the component
Method update Updates this component's metadata
Property is_empty Whether this component's data is empty
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
def get(cls, data: bytes, **kwargs) -> Self: (source)

Converts bytes -> TIComponent

Parameters
data:bytesThe raw bytes to convert
**kwargsUndocumented
Returns
SelfA TIComponent instance with data equal to data
def get_type(cls, *, type_id: int = None, name: str = None, extension: str = None) -> type[Self] | None: (source)

Gets the subclass corresponding to a type ID, type name, or file extension if one is registered

Parameters
type_id:intThe type ID to search by, or
name:strThe type name to search by, or
extension:strThe file extension to search by
Returns
type[Self] | NoneA subclass of this component with corresponding type ID or extension, or None
def open(cls, filename: str) -> Self: (source)

Creates a new component from a file given a filename

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

Registers a subtype with this class for coercion

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

Converts TIComponent -> bytes

Parameters
value:SelfThe value to convert
**kwargsUndocumented
Returns
bytesThe data of value
def __bool__(self) -> bool: (source)
Returns
boolWhether this component's data is empty
def __bytes__(self) -> bytes: (source)
Returns
bytesThe bytes contained in this component
def __copy__(self) -> Self: (source)
Returns
SelfA copy of this component
def __eq__(self, other) -> bool: (source)

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

Parameters
otherThe component to check against
Returns
boolWhether this component is equal to other
def __init__(self, init=None, *, name: str = 'UNNAMED', data: bytes = None): (source)

Creates an empty component with specified data

Parameters
initValues to initialize the component's data (defaults to None)
name:strUndocumented
data:bytesThe component's data (defaults to empty)
def __len__(self) -> int: (source)
Returns
intThe total length of this component's bytes
def __str__(self) -> str: (source)
Returns
strA string representation of this component
def bytes(self) -> bytes: (source)
Returns
bytesThe bytes contained in this component
def clear(self): (source)
overridden in tivars.var.TIEntry

Clears this component's data

def coerce(self): (source)

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

Valid types must be registered to be considered for coercion.

def dict(self, **kwargs) -> dict: (source)
overridden in tivars.var.TIEntry
Returns
dictA JSON dictionary representation of this component
def get_extension(self, model: TIModel = TI_84PCE) -> str: (source)

Determines the file extension for a targeted model based on its contents

Parameters
model:TIModelThe model to target (defaults to TI_84PCE)
Returns
strThe file's extension
def json(self, **kwargs) -> dict: (source)
Returns
dictA JSON dictionary representation of this component
def load_bytes(self, data: bytes | BytesIO): (source)

Loads a byte string or bytestream into this component

Parameters
data:bytes | BytesIOThe bytes to load
def load_dict(self, dct: dict, **kwargs): (source)
overridden in tivars.var.TIEntry

Loads this component from a JSON dictionary representation

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

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

Parameters
file:BinaryIOA binary file to read from
offset:intThe offset of the component to read
def load_json(self, dct: dict, **kwargs): (source)

Loads this component from a JSON dictionary representation

Parameters
dct:dictThe dict to load
**kwargsUndocumented
def load_string(self, string: str, **kwargs): (source)

Loads this component from a string representation

If there is no dedicated handler for a component type, all subclasses of the type will be considered.

Parameters
string:strThe string to load
**kwargsUndocumented
def name(self) -> str: (source)

The name of the component

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

Saves this component as a complete file in the current directory given a filename and optional targeted model

Parameters
filename:strA filename to save to (defaults to the component's name and extension)
model:TIModelA TIModel to target (defaults to TI_84PCE)
def string(self, **kwargs) -> str: (source)
Returns
strA string representation of this component
def summary(self) -> str: (source)
Returns
strA text summary of this component
def type_id(self) -> int: (source)

The (first) type ID of the component

def update(self): (source)

Updates this component's metadata

All attributes self.<name> are set to self.get_<name>() if possible.

Whether this component's data is empty

_type_ids: dict[int, type[Self]] = (source)

Undocumented