From 9034c3d2533177f7cb7a7ce939ec53f7fa63f60e Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 13 Apr 2021 16:16:27 -0400 Subject: Added spells --- parser/scrapeToJson.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'parser/scrapeToJson.py') 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)) -- cgit v1.2.3