update mhx skill trees, add skills

This commit is contained in:
Bryce Allen
2015-12-11 23:08:27 -06:00
parent 44e62b01dc
commit 7f2136ad41
3 changed files with 472 additions and 7 deletions

View File

@@ -25,28 +25,47 @@ import requests
#<td rowspan="1" style="vertical-align: top; background-color: #ddeeee; font-size:12pt; border-bottom: 2px solid #000000;"><h3><span class="mw-headline" id="Ammo_Saver">Ammo Saver</span></h3>弾薬節約
TREE_RE = re.compile('^<td [^>]*><h[23]><span class="mw-headline" id="[^"]*">(?:<b>)?([^<]*)(?:</b>)?</span></h[23]>([^<]*)')
SKILL_RE = re.compile(
'</td><td style="color: #000000;[^>]*> ([^<]*)<br />(.*)')
TREE_END = '</td></tr>'
def parse_wikia_skill_trees(f):
data = []
strees = []
skills = []
seen = set()
in_tree = False
while True:
line = f.readline()
if not line:
break
line = line.strip()
if in_tree:
if line == TREE_END:
in_tree = False
continue
m = SKILL_RE.match(line)
if m:
skill = dict(name=m.group(1), name_jp=m.group(2))
skills.append(skill)
continue
m = TREE_RE.match(line)
if m:
stree = dict(name=m.group(1), name_jp=m.group(2))
if stree["name"] not in seen:
data.append(stree)
strees.append(stree)
seen.add(stree["name"])
return data
in_tree = True
return strees, skills
def _main():
with open(sys.argv[1]) as f:
stree_list = parse_wikia_skill_trees(f)
print json.dumps(stree_list, indent=2)
strees, skills = parse_wikia_skill_trees(f)
print json.dumps(strees, indent=2)
print json.dumps(skills, indent=2)
if __name__ == '__main__':