pytoc
A Python package for reading and writing World of Warcraft addon TOC files.
Installation
pip install wow-pytoc
Usage
Reading a TOC file
from pytoc import TOCFile, TOCTextLocale
toc = TOCFile("path/to/MyAddon.toc")
print(toc.Interface) # TOCListValue[int] of all interface versions
print(toc.Title) # base (enUS) value
print(toc.Title.get_translation(TOCTextLocale.frFR))
print(toc.ExtendedDirectives.get("X-Website"))
print(toc.UnknownDirectives.get("SomeUnknownField"))
for dep in toc.Dependencies:
print(f"Required: {dep}")
for dep in toc.OptionalDeps:
print(f"Optional: {dep}")
for file_line in toc.Files:
entry = file_line.FileEntry
print(entry.export())
Writing a TOC file
from pytoc import TOCFile, TOCLocalizedDirectiveValue, TOCListValue, TOCTextLocale
toc = TOCFile()
toc.Interface = TOCListValue("110000", [110000])
toc.Author = TOCLocalizedDirectiveValue("Ghost")
toc.Title = TOCLocalizedDirectiveValue(
"MyAddon",
{TOCTextLocale.frFR: "MonAddon", TOCTextLocale.deDE: "MeinAddon"},
)
toc.add_file("MyAddon.lua")
toc.add_file("MyAddon.xml")
toc.add_dependency("totalRP3", required=False)
toc.export("path/to/MyAddon.toc", overwrite=True)
Round-trip
Reading and exporting an existing file produces byte-identical output.
toc = TOCFile("MyAddon.toc")
toc.Author = TOCLocalizedDirectiveValue("NewAuthor")
toc.export("MyAddon.toc", overwrite=True)
# Every line unchanged except ## Author:
Load condition simulation
TOCEvaluationContext lets you simulate whether an addon (or a specific file entry) would load under given game conditions.
from pytoc import (
TOCFile, TOCEvaluationContext, TOCAllowLoadGameType,
TOCGameType, TOCEnvironment, TOCTextLocale,
)
ctx = TOCEvaluationContext(TOCGameType.Mainline, TOCEnvironment.Global, TOCTextLocale.enUS)
toc = TOCFile("MyAddon.toc")
can_load, err = toc.can_load_addon(ctx)
# Per-file entry
for file_line in toc.Files:
if file_line.FileEntry.should_load(ctx):
print(file_line.FileEntry.resolve_path(ctx))
Notes/Quirks
Metadata
Release files for wow-pytoc 0.8.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wow_pytoc-0.8.0.tar.gz | 11.6 kB | Without provenance | Details for wow_pytoc-0.8.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wow_pytoc-0.8.0-py3-none-any.whl | Python 3 | none | any | Details for wow_pytoc-0.8.0-py3-none-any.whl |
Total release size: 26.4 kB
Release files / wow_pytoc-0.8.0.tar.gz
| Download URL | wow_pytoc-0.8.0.tar.gz |
|---|---|
| Size | 11.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8fe9e1179b86aed855bead9b43584d3db7984b733ce5136151226f76dce3c43d
|
|
BLAKE2b-256 checksum How to use checksums |
f98d75791c455c480d041a94a4a08f3ad98383ca936d78745d06e2fe94f41026
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / wow_pytoc-0.8.0-py3-none-any.whl
| Download URL | wow_pytoc-0.8.0-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ee3dc144fd8f8213ccf38afd743abccac19f2203f8eaf99614dd15159d81869
|
|
BLAKE2b-256 checksum How to use checksums |
6572be4d3087fac08f6acdaab799aa030e8afd998548f731a8014d6b6c1c8567
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.8 {"installer":{"name":"uv","version":"0.11.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for wow-pytoc 0.8.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.