Skip to main content

Python bindings and Rust tooling for working with KingsIsle class and binary XML data

Project description

kiclass

kiclass is a Rust-powered Python extension for working with KingsIsle class definition files and binary XML data.

It can:

  • load class tables from .cdb definition files,
  • convert definition XML files into .cdb,
  • merge client and server definition tables,
  • deserialize KI binary XML files into dynamic Python objects,
  • serialize parsed objects back to JSON or XML,
  • expose the hashing helpers used by Wizard101 and Pirate101.

Install

From PyPI:

pip install kiclass

From source:

maturin develop --release

To build a wheel manually:

maturin build --release

CDB Setup

kiclass loads class definitions from .cdb files. These are compiled class tables generated from KingsIsle definition XML files.

Typical layout:

ClientDefs.xml
ServerDefs.xml
ClientDefs.cdb
ServerDefs.cdb
MergedDefs.cdb

Recommended workflow:

  1. Obtain ClientDefs.xml and ServerDefs.xml.
  2. Convert each XML file into a .cdb file.
  3. Merge the client and server .cdb files into one combined table.
  4. Load MergedDefs.cdb when reading binary XML files.

Example:

from kiclass import Mode, convert_xml_to_cdb, merge_cdb_defs

convert_xml_to_cdb("ClientDefs.xml", "ClientDefs.cdb", Mode.Wizard)
convert_xml_to_cdb("ServerDefs.xml", "ServerDefs.cdb", Mode.Wizard)
merge_cdb_defs("ClientDefs.cdb", "ServerDefs.cdb", "MergedDefs.cdb")

If you are working with Pirate101 data, use Mode.Pirate when generating the .cdb files.

kiclass expects the current .cdb file format. If your generated files are stale or invalid, regenerate them from the XML sources instead of relying on backwards compatibility.

Usage

Load a class table and read a binary XML file

from kiclass import KIBinaryFileReader, load_classes

classes = load_classes("MergedDefs.cdb")
reader = KIBinaryFileReader(classes)

result = reader.read_file("some_file.xml")

if result is None:
	print("Not a valid KI binary XML file")
elif not result.is_known():
	print(f"Unknown class id: {result.id()}")
else:
	print(result.class_name())
	print(result.to_json())

Create a class from the loaded table

from kiclass import load_classes

classes = load_classes("MergedDefs.cdb")
obj = classes.create_class("ClientObject")

if obj is not None:
	print(obj.class_name())
	print(obj.to_json())

Use the hashing helpers

from kiclass import Mode, hash_field_type, light_hash_string, wiz_hash_string

print(wiz_hash_string("ClientObject"))
print(light_hash_string("string"))
print(hash_field_type("m_templateID", "unsigned int", Mode.Wizard))

Notes

  • read_file() returns a dynamic class for known data, UnknownClass for valid but unmapped data, and None for invalid binary XML.
  • The loader expects .cdb files generated in the current format.
  • The repository includes scripts such as convert_worlddata.py and the easy_deserialize tooling for larger batch workflows.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kiclass-0.2.0.tar.gz (44.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

kiclass-0.2.0-cp310-abi3-win_amd64.whl (554.0 kB view details)

Uploaded CPython 3.10+Windows x86-64

kiclass-0.2.0-cp310-abi3-manylinux_2_34_x86_64.whl (628.4 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.34+ x86-64

File details

Details for the file kiclass-0.2.0.tar.gz.

File metadata

  • Download URL: kiclass-0.2.0.tar.gz
  • Upload date:
  • Size: 44.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kiclass-0.2.0.tar.gz
Algorithm Hash digest
SHA256 8b5604b32207b81f5a2fc6b9965270229f417227d96bb1f9581ad68fcaee157f
MD5 81b831ff5f831df26b7bfbf21d37ff04
BLAKE2b-256 d820bd1a9109a6c9bfeee206652c1e63a56c5856a642774b8ad6c1d9c0a54639

See more details on using hashes here.

File details

Details for the file kiclass-0.2.0-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: kiclass-0.2.0-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 554.0 kB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for kiclass-0.2.0-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 3e84630c9c3975b9fa322fbc89a42361ed064918d788c90b6dcef10753ce4f0f
MD5 255d5ec34c1cc6784d12940b3ec68346
BLAKE2b-256 1582b412ac7460c0402ef2e8df9beea8a6ec01e21efd4f092a1964006592e940

See more details on using hashes here.

File details

Details for the file kiclass-0.2.0-cp310-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for kiclass-0.2.0-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 23d3f205ad2ab0873d4f571ea2d0e99f00ec3531a027248d62a2f3bf01a1bb39
MD5 c9ae8e1f74d18e322b6948f0dd7565bb
BLAKE2b-256 c254c1b54bb33aa20cae0727a27313f58e14b81c58ebbad5dc00bfd8fdafdb4d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page