WotLK M2 files parser
Project description
m2lk
WotLK M2 files parser
from m2lk import M2FileReader, M2, M2Skin
with M2FileReader(filename) as reader:
m2 = M2()
m2.load(reader)
with M2FileReader(skin_filename) as reader:
skin = M2Skin()
skin.load(reader)
And then m2
can be used as a structure.
M2Field
Feild's value can be obtained with value
property. For example:
m2.value
m2.name.value
The value is a JSON-srializable data.
M2ArrayField
M2ArrayField is a subclass of M2Field. Its item can be obtained by index. For example:
if len(m2.sequences) > 0:
sequence_0_field = m2.sequences[0] # M2Field instance
sequence_0_field.movespeed.value # float
M2Struct
M2Struct is a subclass of M2Field.
fields
property is a dict {field_name: field}
.
For example M2 structure fields can be obtained with list(m2.fields)
.
Structure field can be obtained by attribute: getattr(obj, field_name)
. For example:
sequences_field = m2.sequences # M2ArrayField
Structure field's value can be obtained by name: obj[field_name]
.
For example JSON-serializable value of sequences
field:
sequences_value = m2['sequences'] # The same as m2.sequences.value
Note: M2
and M2Skin
are subclasses of M2Struct
.
JSON
A m2 value can be saved to a json file:
import json
m2_json = json.dumps(m2.value)
And then loaded to a M2 structure:
m2 = M2()
m2.from_json(json.loads(m2_json))
The same is for M2Skin:
import json
skin_json = json.dumps(skin.value)
skin_new = M2Skin()
skin_new.from_json(json.loads(skin_json))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file m2lk-0.0.2.tar.gz
.
File metadata
- Download URL: m2lk-0.0.2.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8fdf231d81964b9a84d705282bacd2616114574526dbcb4dfd7448a6ea6e8ab |
|
MD5 | 30234702cfcf0d7e74c52015a5278eca |
|
BLAKE2b-256 | c81dcad9973b91993059cd1c3f191b1767cbd76f67ac73b4f274db71084ecf2b |
File details
Details for the file m2lk-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: m2lk-0.0.2-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.9.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 391e0956624ab565fe869db075d3b43ed27b08bba3b96fa337e2d8533bcab6c7 |
|
MD5 | c4832e45814b80e4d7c36e99abc33a69 |
|
BLAKE2b-256 | 764b07cbd5675b6f93fad43318010dc5d883f0537bf61ee3bc8e28db7af33aa0 |