aboutsummaryrefslogtreecommitdiff
path: root/parser
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-05-01 15:34:12 -0400
committerYour Name <you@example.com>2021-05-01 15:34:12 -0400
commit6e41af7248b4e594d1b538a5989c9d0998b53cca (patch)
tree2e58dc57bdc9893ea2bca4cb8310f5d22e4da762 /parser
parent7b5d1e3d46e94262a9c0fd3a01ab4685aea9d12d (diff)
downloaddmtool-6e41af7248b4e594d1b538a5989c9d0998b53cca.tar.gz
dmtool-6e41af7248b4e594d1b538a5989c9d0998b53cca.tar.bz2
dmtool-6e41af7248b4e594d1b538a5989c9d0998b53cca.zip
Made data source a git module
Diffstat (limited to 'parser')
m---------parser/5thSRD0
-rwxr-xr-xparser/scrapeToJson.py4
-rwxr-xr-xparser/utils.py6
3 files changed, 7 insertions, 3 deletions
diff --git a/parser/5thSRD b/parser/5thSRD
new file mode 160000
+Subproject 5356ad7fc35f76891c64cd36159cc42a04c9c71
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()