darkest-parser
darkest-parser is a module to parser .darkest file originally from Darkest Dungeon programatically.
Usage
pip install darkest-parser
from darkest_parser import parse, unparse
text = '''
resistances: .stun 40% .poison 40% .bleed 40% .disease 30% .move 40% .debuff 30% .death_blow 67% .trap 40%
weapon: .name "houndmaster_weapon_0" .atk 0% .dmg 4 7 .crit 4% .spd 5
armour: .name "houndmaster_armour_0" .def 10% .prot 0 .hp 21 .spd 0
combat_skill: .id "hounds_rush" .level 0 .type "ranged" .atk 85% .dmg 0% .crit 5% .launch 432 .target 1234 .effect "Beast Killer 1"
combat_skill: .id "hounds_rush" .level 1 .type "ranged" .atk 90% .dmg 0% .crit 6% .launch 432 .target 1234 .effect "Beast Killer 2"
'''
dark = parse(text)
dark[0].tag == 'resistances'
dark[0].set('stun', '60%')
dark[0].poison = '40%'
weapon0 = dark.find('weapon', name='houndmaster_weapon_0')
weapon0.tag == 'weapon'
weapon0.dmg = [14, 17]
weapon0.spd = 25
for rush in dark.finditer('combat_skill', id='hounds_rush'):
rush.type = 'meele'
rush.set('ignore_guarded')
rush0 = dark.find(id='hounds_rush', level=0)
# x invalid:
# rush0.effect.append('Human Killer 1')
# √ use instead:
rush0.effect = [*rush0.effect, 'Human Killer 1']
rush1 = dark.find(id='hounds_rush', level=1)
rush1.has('target') == True
rush1.set('target', '~1234', 'literal')
# literal means that the value is unquoted, it's useful in some case,
# for example: launch, target, valid_modes, etc.
print(unparse(dark))
API Reference
def parse(str) -> Darkest:
...
def unparse(Darkest) -> str:
...
class Darkest:
def __getitem__(int) -> Element:
...
def finditer(str | None, **{str: Any}) -> Generator[Element, Any, Any]:
...
def findall(str | None, **{str: Any}) -> List[Element]:
...
def find(str | None, **{str: Any}) -> Element:
...
class Element:
def get(str) -> List[Any]:
...
def set(str, Any | List[Any] | None, Literal['number', 'bool', 'string', 'literal'] | None):
...
def pop(str):
...
def has(str) -> bool:
...
Metadata
Release files for darkest-parser 1.1.1
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 |
|---|---|---|---|---|
| darkest_parser-1.1.1.tar.gz | 3.4 kB | Without provenance | Details for darkest_parser-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| darkest_parser-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for darkest_parser-1.1.1-py3-none-any.whl |
Total release size: 7.5 kB
Release files / darkest_parser-1.1.1.tar.gz
| Download URL | darkest_parser-1.1.1.tar.gz |
|---|---|
| Size | 3.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
879865922565d8984e9b2fbc73602eebe270b0c9fbd6cd909333cc1f189c8e4c
|
|
BLAKE2b-256 checksum How to use checksums |
29c960645cb48e7bc62e0ec8774e638f65c04dca40b9bbed54e054532f711fa3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.12.0 Windows/10
|
Release files / darkest_parser-1.1.1-py3-none-any.whl
| Download URL | darkest_parser-1.1.1-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
364f73590370a88ddb331574580e60a3b58d9d6c7a72ce2102a343f302ababe8
|
|
BLAKE2b-256 checksum How to use checksums |
cff0210280696097b1f7e986bf9e37a05fd26ff2e45f2603dd9d2d09a75ea28f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.6.1 CPython/3.12.0 Windows/10
|
Security for darkest-parser 1.1.1
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.