NIB Object Model

class nibarchive.NIBArchiveHeader(unknown_1: int, unknown_2: int, object_count: int, offset_objects: int, key_count: int, offset_keys: int, value_count: int, offset_values: int, class_name_count: int, offset_class_names: int)

Represents the header of a NIB archive.

The header contains information about the archive, such as the number of objects, keys, values, and class names present in the archive.

Parameters:
  • unknown_1 (int) – Unknown value 1.

  • unknown_2 (int) – Unknown value 2.

  • object_count (int) – Number of objects in the archive.

  • offset_objects (int) – Offset to the objects in the archive.

  • key_count (int) – Number of keys in the archive.

  • offset_keys (int) – Offset to the keys in the archive.

  • value_count (int) – Number of values in the archive.

  • offset_values (int) – Offset to the values in the archive.

  • class_name_count (int) – Number of class names in the archive.

  • offset_class_names (int) – Offset to the class names in the archive.

class nibarchive.ClassName(length: int, extras_count: int, name: str, extras: list[int] = <factory>)

Represents a class name in a NIB archive.

Class names are used to identify the class type of objects in the archive.

Parameters:
  • length (int) – Length of the class name (varint).

  • extras_count (int) – Number of extra integers following the name (varint).

  • name (str) – Name of the class.

  • extras (list[int]) – Extra integers associated with the class (default: empty list).

class nibarchive.NIBKey(length: int, name: str)

Represents a key in a NIB archive.

Keys are used to identify the values associated with objects.

Parameters:
  • length (int) – Length of the key (varint).

  • name (str) – Name of the key.

class nibarchive.NIBValueType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

Enum representing the possible value types in a NIB archive.

The value types define the type of data stored in a NIBValue object.

Parameters:
  • INT8 – 8-bit integer.

  • INT16 – 16-bit integer.

  • INT32 – 32-bit integer.

  • INT64 – 64-bit integer.

  • BOOL_TRUE – Boolean value true.

  • BOOL_FALSE – Boolean value false.

  • FLOAT – Single-precision floating-point number.

  • DOUBLE – Double-precision floating-point number.

  • DATA – Data object.

  • NIL – Nil value.

  • OBJECT_REF – Object reference.

static from_byte(value: int) NIBValueType

Get the NIBValueType enum value from a byte representation.

Parameters:

value (int) – Byte value representing the NIBValueType.

Returns:

Corresponding NIBValueType enum value.

Return type:

NIBValueType

Raises:

ValueError – If the byte value does not match any NIBValueType.

class nibarchive.NIBValue(key_index: int, type: NIBValueType, data: Any = None)

Represents a value in a NIB archive.

Values are associated with keys and hold data for objects.

Parameters:
  • key_index (int) – Index of the associated NIBKey (varint).

  • type (:class`NIBValueType`) – Type of the value.

  • data (Any) – Data associated with the value (default: None).

class nibarchive.NIBObject(class_name_index: int, values_index: int, value_count: int)

Represents an object in a NIB archive.

Objects are instances of classes defined in the archive.

Parameters:
  • class_name_index (int) – Index of the associated ClassName (varint).

  • values_index (int) – Index of the first associated NIBValue (varint).

  • value_count (int) – Number of associated values (varint).

class nibarchive.NIBArchive(header: ~nibarchive.model.NIBArchiveHeader, objects: list[~nibarchive.model.NIBObject] = <factory>, keys: list[~nibarchive.model.NIBKey] = <factory>, values: list[~nibarchive.model.NIBValue] = <factory>, class_names: list[~nibarchive.model.ClassName] = <factory>)

A simple NIB archive dataclass.

Parameters:
  • header (NIBArchiveHeader) – Header of the NIB archive.

  • objects (list[NIBObject]) – List of NIBObject instances (default: empty list).

  • keys (list[NIBKey]) – List of NIBKey instances (default: empty list).

  • values (list[NIBValue]) – List of NIBValue instances (default: empty list).

  • class_names (list[ClassName]) – List of ClassName instances (default: empty list).

get_class_name(obj: NIBObject) ClassName

Get the ClassName associated with a given NIBObject.

Parameters:

obj (NIBObject) – The NIBObject.

Returns:

The associated ClassName.

Return type:

ClassName

get_object_items(obj: NIBObject) dict[NIBKey, NIBValue]

Get a dictionary of NIBKey-NIBValue pairs associated with a given NIBObject.

Parameters:

obj (NIBObject) – The NIBObject.

Returns:

The dictionary of NIBKey-NIBValue pairs associated with the object.

Return type:

Dict[NIBKey, NIBValue]

get_object_values(obj: NIBObject) list[NIBValue]

Get the list of NIBValues associated with a given NIBObject.

Parameters:

obj (NIBObject) – The NIBObject.

Returns:

The list of NIBValues associated with the object.

Return type:

List[NIBValue]

get_value_key(value: NIBValue) NIBKey

Get the NIBKey associated with a given NIBValue.

Parameters:

value (NIBValue) – The NIBValue.

Returns:

The associated NIBKey.

Return type:

NIBKey