diff options
author | Your Name <you@example.com> | 2021-04-13 16:16:27 -0400 |
---|---|---|
committer | Your Name <you@example.com> | 2021-04-13 16:16:27 -0400 |
commit | 9034c3d2533177f7cb7a7ce939ec53f7fa63f60e (patch) | |
tree | 49bf01a4682c251cb3778f563afeb7e1ec8d41c7 /parser/scrapeToJson.py | |
parent | 2ab51e507d620c4479e07ca0ec47d22c8c66bc90 (diff) | |
download | dmtool-9034c3d2533177f7cb7a7ce939ec53f7fa63f60e.tar.gz dmtool-9034c3d2533177f7cb7a7ce939ec53f7fa63f60e.tar.bz2 dmtool-9034c3d2533177f7cb7a7ce939ec53f7fa63f60e.zip |
Added spells
Diffstat (limited to 'parser/scrapeToJson.py')
-rwxr-xr-x | parser/scrapeToJson.py | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/parser/scrapeToJson.py b/parser/scrapeToJson.py index 57fcbbc..d9444c7 100755 --- a/parser/scrapeToJson.py +++ b/parser/scrapeToJson.py @@ -215,15 +215,17 @@ def processMonster(data, weapons, armors): from pathlib import Path weapons = utils.getWeapons() armors = utils.getArmor() -Path('items/weapons/').mkdir(parents=True, exist_ok=True) -for weapon in weapons: - with open('items/weapons/' + weapon['name'].replace(' ', '_') + '.json', 'w') as f: - json.dump(weapon, f, indent=2) -# Also do armors -Path('items/armor/').mkdir(parents=True, exist_ok=True) -for armor in armors: - with open('items/armor/' + armor['name'].replace(' ', '_') + '.json', 'w') as f: - json.dump(armor, f, indent=2) +spells = utils.getSpells() + +def dumpStuff(stuff, destDir): + Path(destDir).mkdir(parents=True, exist_ok=True) + for thing in stuff: + with open(destDir + '/' + thing['name'].replace(' ', '_').replace('/', '') + '.json', 'w') as f: + json.dump(thing, f, indent=2) + +dumpStuff(weapons, 'items/weapons/') +dumpStuff(armors, 'items/armor/') +dumpStuff(spells, 'spells/') for monster in Path('../../5thSRD/docs/gamemaster_rules/monsters/').glob('*.md'): #print('Processing {}'.format(monster)) |