Skip to main content

Read, modify and write files used by KotOR's game engine.

Project description

PyKotor

PyPI docs license: LGPL v3+ CI pre-commit

PyKotor is a modern Python library and toolset for reading, writing, and modding resources from the Star Wars: Knights of the Old Republic (KOTOR, K1) and The Sith Lords (KOTOR II, TSL) game engines.


Features

  • Read and write almost all K1/TSL resource and file formats (BIF, ERF, GFF, KEY, TLK, DLG, UTC, UTP, UTI, UTS, etc.)
  • Support for both K1 (swkotor.exe) and TSL (swkotor2.exe) with unified APIs
  • High-fidelity, reverse-engineered format logic and type safety
  • Command-line toolkit (pykotorcli) for file conversion, inspection, and batch operations
  • Programmatic API for advanced automation and mod tooling
  • Modern, type-checked, actively maintained, and well-tested codebase

Documentation & Community

Quick Install

pip install pykotor

Or with extras for format encodings and update tool:

pip install "pykotor[encodings,updater]"

CLI Example

# Convert a BIF file to readable resources
pykotorcli extract-bif --input KOTOR1/BIFs/data.bif --output ./output_dir

# Inspect a GFF (generic file format)
pykotorcli gff-dump --file some_file.uti

# See all CLI features
pykotorcli --help

Python Usage Example

from pykotor.tsl.gff import GFF

# Parse a .utc (creature) file
gff = GFF.parse("dan13_01.utc")
print(gff.root["FirstName"].string)  # Accessing the field value

# Modify and save
gff.root["FirstName"].string = "HK-47"
gff.write("hk_utc.gff")

Supported Formats

Major types:

  • Containers: BIF, ERF, KEY, MOD, RIM
  • Resources: GFF/UT*, GIT, DLG, ARE, UTP, UTI, UTC, UTS, UTM, UTR, UTT, JRL, TLK, etc.
  • 2DA, SSF, NCS/NSS, NDB, models, textures, etc. See Wiki Format Coverage.

Development & Contributing

  1. Clone the repo and install Poetry or use uv.
  2. poetry install or uv pip install -e .[dev]
  3. Run pytest and ruff check . and mypy --strict before submitting PRs.

For feature requests, new formats, or reverse-engineering findings, see CONTRIBUTING.md.


License

LGPL-3.0-or-later (see LICENSE)


This project follows unified K1/TSL reverse engineering practices. All resource logic is verified across both game engines using REVA MCP tools. See the Wiki for details on our protocol.

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

pykotor-2.3.9.tar.gz (2.3 MB view details)

Uploaded Source

Built Distribution

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

pykotor-2.3.9-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

Details for the file pykotor-2.3.9.tar.gz.

File metadata

  • Download URL: pykotor-2.3.9.tar.gz
  • Upload date:
  • Size: 2.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pykotor-2.3.9.tar.gz
Algorithm Hash digest
SHA256 77bcddb372f49e1a8bce455a02a005d89cfa31dc434997b32c44364c80a31ccf
MD5 c111c57ab54354cf6514b7375d1230f8
BLAKE2b-256 7f19d4c5727306405f62098e5fb2e3b096eb4d80cb7b2093d0d8605c8e9af8d7

See more details on using hashes here.

File details

Details for the file pykotor-2.3.9-py3-none-any.whl.

File metadata

  • Download URL: pykotor-2.3.9-py3-none-any.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pykotor-2.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 6744afd57a8523903c3c2f0d3a55e8a6504bd15d3a38b753838757c6e05fe1d5
MD5 dfab6ae04f0d012009ae67881fce1f87
BLAKE2b-256 4b7d34f7bc91db877d63fc4e4df8920902854cf708836f3270fb196549c25f1f

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