1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.
Status
About
This is a Python parser for Arma 3 class definitions such as those appearing inside unrapified mission files.
It's based on Fusselwurm's arma-class-parser that is written JavaScript.
I grew tired of using it in conjunction with PyExecJS (complicated to set up and needing to patch things up on Windows) and py2js (too slow to parse even 300KB sqm files) and decided to port the original JavaScript code to Python.
Installation
pip install armaclass
Usage
Parse the values from a string
In [1]: import armaclass
In [2]: armaclass.parse('version=12;\n\nclass Moo {\r\n value = 1; };')
Out[2]: {'Moo': {'value': 1.0}, 'version': 12.0}
Keep the values ordered as they were in the original file
In [3]: armaclass.parse('version=12;\n\nclass Moo {\r\n value = 1; };', keep_order=True)
Out[3]: OrderedDict([('version', 12.0), ('Moo', OrderedDict([('value', 1.0)]))])
Note: Starting with Python 3.7 onwards, dicts are always ordered so it
doesn't matter if you use keep_order or not.
Generate the files based on a parsed (or manually created) structure
In [4]: from collections import OrderedDict
In [5]: structure = OrderedDict([('version', 12.0), ('Moo', OrderedDict([('value', 1.0)]))])
In [6]: print(armaclass.generate(structure))
version=12;
class Moo
{
value=1;
};
Indent with tabs instead of spaces
In [7]: print(armaclass.generate(structure, indent=1, use_tabs=True))
version=12;
class Moo
{
value=1;
};
Extending the generator
You can use this library to write a program that will port your Arma class files to DayZ, for example.
To do so, you will need to create your own generator by subclassing armaclass.generator.Generator and implementing
your own methods (the ones raising NotImplemented).
Development
Notes
The naming conventions may not match Python's pep8 as I was trying to stay close to the original parsing names to facilitate porting. Those (internal) names may be changed in the future.
Making code changes
- Create a virtualenv using your preferred method (mkvirtualenv, venv, etc...)
pip install -r requirements.txt- Write code AND tests
pytestto test run your testsptw -nif you wantpytestto automatically be called whenever you save any file from the project
Contributing
If you feel something is missing or plain wrong, feel free to submit a Pull Request. You are encouraged to submit the same PR/suggestion to the original arma-class-parser as well.
Metadata
Release files for armaclass 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
File added late
1 file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| armaclass-0.2.2.tar.gz | 5.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| armaclass-0.2.2-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 12.9 kB
Release files / armaclass-0.2.2.tar.gz
| Download URL | armaclass-0.2.2.tar.gz |
|---|---|
| Size | 5.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b7903e9ff4ea2b9b3e0e25306e1100743cdeb6b4c9c81799c617e0574c737ace
|
|
BLAKE2b-256 checksum How to use checksums |
034da8c543a6a0c0522ca58cc261443714b553dce0589ee299aecb6d5dec962e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.9
|
Release files / armaclass-0.2.2-py2.py3-none-any.whl
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | armaclass-0.2.2-py2.py3-none-any.whl |
|---|---|
| Size | 7.2 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
fb6306d0f96c755242e9a2a7aaee0b6d930f7d0e3a560b6153d1c110047f3d0d
|
|
BLAKE2b-256 checksum How to use checksums |
6ef1b6e5d8a4960a5a14ad5d8e51c1065f0b765d311a47e9cbc93b04f3a4d6ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.1
|