From 6e41af7248b4e594d1b538a5989c9d0998b53cca Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 1 May 2021 15:34:12 -0400 Subject: Made data source a git module --- parser/5thSRD | 1 + parser/scrapeToJson.py | 4 +++- parser/utils.py | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) create mode 160000 parser/5thSRD (limited to 'parser') diff --git a/parser/5thSRD b/parser/5thSRD new file mode 160000 index 0000000..5356ad7 --- /dev/null +++ b/parser/5thSRD @@ -0,0 +1 @@ +Subproject commit 5356ad7fc35f76891c64cd36159cc42a04c9c71d diff --git a/parser/scrapeToJson.py b/parser/scrapeToJson.py index fd8403d..21758d0 100755 --- a/parser/scrapeToJson.py +++ b/parser/scrapeToJson.py @@ -6,7 +6,7 @@ import utils def processMonster(data, weapons, armors, spells): names2names = {'ac': 'Armor Class', 'hp': 'Hit Points', 'speed': 'Speed', 'saves': 'Saving Throws', 'd_resistances': 'Damage Resistances?', 'd_vulnerabilities': 'Damage Vulnerabilities', 'd_immunities': 'Damage Immunities', 'c_immunities': 'Condition Immunities', 'senses': 'Senses', 'langs': 'Languages', 'skills': 'Skills'} - desc = {'entry': 'creature'} + desc = {'entry': 'creatures'} for name in names2names: m = re.search('(\*\*{}\.?\*\*)(.*)'.format(names2names[name]), data) if m: @@ -292,6 +292,8 @@ dumpStuff(spells, 'parsed/spells/') for monster in Path(utils.docsLoc + '/gamemaster_rules/monsters/').glob('*.md'): #print('Processing {}'.format(monster)) + if monster.name == 'index.md': + continue with monster.open() as f: data = f.read() Path('parsed/creatures/').mkdir(exist_ok=True) diff --git a/parser/utils.py b/parser/utils.py index 34649ca..645bc96 100755 --- a/parser/utils.py +++ b/parser/utils.py @@ -4,7 +4,7 @@ import json import re from fractions import Fraction -docsLoc = '../5thSRD/docs/' +docsLoc = 'parser/5thSRD/docs/' skillsByAbility = {'str': ['Athletics'], 'dex': ['Acrobatics', 'Sleight of Hand', 'Stealth'], 'con': [], 'int': ['Arcana', 'History', 'Investigation', 'Nature', 'Religion'], 'wis': ['Animal Handling', 'Insight', 'Medicine', 'Perception', 'Survival'], 'cha': ['Deception', 'Intimidation', 'Performance', 'Persuasion']} @@ -163,9 +163,11 @@ def getSpells(): names2names = {'name': 'name', 'level': 'level', 'type': 'school', 'classes': 'classes', 'casting_time': 'Casting Time', 'range': 'Range', 'components': 'Components', 'duration': 'Duration'} from pathlib import Path for s in Path(docsLoc + '/spellcasting/spells/').iterdir(): + if s.name == 'index.md': + continue with s.open() as f: data = f.read() - spell = {'entry': 'spell'} + spell = {'entry': 'spells'} for name in names2names: spell[name] = re.search('(?sm)[\*]*{}[\*:]* (.*?)^[a-zA-Z#\*]'.format(names2names[name]), data).group(1).strip() spell['name'] = spell['name'].lower() -- cgit v1.2.3