diff options
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)) |