update translate site for mhxx

This commit is contained in:
Bryce Allen
2017-04-26 18:22:36 -05:00
parent a791588490
commit 084870858e
9 changed files with 2148 additions and 399 deletions

View File

@@ -11,7 +11,7 @@ from mako.runtime import Context
import _pathfix
from mhapi.db import MHDB
#from mhapi.db import MHDB
from mhapi.util import get_utf8_writer
tlookup = TemplateLookup(directories=["templates/translate"],
@@ -86,7 +86,7 @@ def _main():
ctx = Context(f)
index_template.render_context(ctx)
db = MHDB()
#db = MHDB(game="mhx")
#strees = db.get_skill_trees()
#items = db.get_items(item_types=("Tool", "Book", "Consumable", "Ammo"))
#gather_items = db.get_items(item_types=
@@ -94,7 +94,7 @@ def _main():
#carve_items = db.get_items(item_types=("Flesh",))
stree_path = os.path.join(_pathfix.project_path, "db", "mhx",
stree_path = os.path.join(_pathfix.project_path, "db", "mhxx",
"skill_tree_list.json")
with open(stree_path) as f:
stree_list = json.load(f)
@@ -154,7 +154,7 @@ def _main():
# ha_list, ("name_jp", "name", "section", "description"),
# jplen_sort_fn, divider_fn=jplen_divider_fn)
monster_path = os.path.join(_pathfix.project_path, "db", "mhx",
monster_path = os.path.join(_pathfix.project_path, "db", "mhxx",
"monster_list.json")
with open(monster_path) as f:
monster_list = json.load(f)

View File

@@ -57,7 +57,7 @@ def parse_wikia_monsters(f):
section = m.group(1)
print >>sys.stderr, "section", section
continue
if section != "Large Monsters":
if section not in ["Large Monsters", "Small Monsters"]:
continue
for m in MONSTER_LINK_RE.finditer(line):
monster = dict(href=m.group(1), name=m.group(2))

View File

@@ -26,8 +26,10 @@ import requests
TREE_RE = re.compile('^<td [^>]*><h[23]><span class="mw-headline" id="[^"]*">(?:<b>)?([^<]*)(?:</b>)?</span></h[23]>([^<]*)')
# <td style="color: #000000;"> Guard +1<br />ガード性能+1
# <td style="color: #ff0000; border-bottom: 2px solid #000000;"> Cold Surge<br />寒さ倍加
# </td><td style="color: #000000; border-bottom: 2px solid #000000;"> Charm Up <img src="data:image/gif;base64,R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAQAICTAEAOw%3D%3D" alt="New" class="lzy lzyPlcHld " data-image-key="New.gif" data-image-name="New.gif" data-src="https://vignette1.wikia.nocookie.net/monsterhunter/images/e/e0/New.gif/revision/latest?cb=20111022174959" width="46" height="12" onload="if(typeof ImgLzy===&#39;object&#39;){ImgLzy.load(this)}" ><noscript><img src="https://vignette1.wikia.nocookie.net/monsterhunter/images/e/e0/New.gif/revision/latest?cb=20111022174959" alt="New" class="" data-image-key="New.gif" data-image-name="New.gif" width="46" height="12" ></noscript><br />護石系統倍加
SKILL_RE = re.compile(
'(?:</td>)?<td style="color: #000000;[^>]*> ([^<]*)<br />(.*)')
'(?:</td>)?<td style="color: #[0f][0f]0000;[^>]*>([^<>]+)((?:<img[^>]* alt="New" [^>]*>)?)(?:<[^>]+>)*<br />(.*)')
def parse_wikia_skill_trees(f):
@@ -35,6 +37,7 @@ def parse_wikia_skill_trees(f):
skills = []
seen = set()
in_tree = 0
is_new = False
while True:
line = f.readline()
if not line:
@@ -46,24 +49,40 @@ def parse_wikia_skill_trees(f):
continue
m = SKILL_RE.match(line)
if m:
skill = dict(name=m.group(1), name_jp=m.group(2))
assert len(m.groups()) == 3
is_new = len(m.group(2)) > 0
stree = strees[-1]
skill = dict(name=m.group(1).strip(), new=is_new,
name_jp=m.group(3).strip(),
tree=stree["name"],
tree_jp=stree["name_jp"])
skills.append(skill)
if is_new:
stree["new"] = True
else:
stree["new"] = False
# next line should be number of points
next_line = f.readline()
points = next_line[next_line.rfind('>')+1:].strip()
skill["points"] = points
continue
m = TREE_RE.match(line)
if m:
stree = dict(name=m.group(1), name_jp=m.group(2))
stree = dict(name=m.group(1).strip(), name_jp=m.group(2).strip())
if stree["name"] not in seen:
strees.append(stree)
seen.add(stree["name"])
# three blank lines divides skill tree rows
in_tree = 3
is_new = False
return strees, skills
def _main():
if len(sys.argv) != 4:
print "Usage: %s infile out_strees.json out_skills.json" % sys.argv[0]
sys.exit(1)
with open(sys.argv[1]) as f:
strees, skills = parse_wikia_skill_trees(f)
with open(sys.argv[2], "w") as f: