#!/usr/bin/env python
import sys
import json
import os.path
import _pathfix
from mhapi.db import MHDB
from mhapi.util import get_utf8_writer
PANEL = """
"""
PANEL2 = """
"""
def print_header_nav(current_page_id):
pages = [("page-skilltrees", "Skill Trees"),
("page-items", "Items"),
("page-hunterarts", "Hunter Arts"),
("page-monsters", "Monsters")]
print """
Menu
"""
def mk_html_list(dict_list, keys, sort_keys, divider_fn=None):
if divider_fn is None:
print ('
')
else:
print ''
def sort_fn(d):
return tuple(d[k] for k in sort_keys)
prev_d = None
if sort_keys is not None:
it = sorted(dict_list, key=sort_fn)
else:
it = dict_list
for d in it:
if divider_fn is not None:
divider_text = divider_fn(d, prev_d)
if divider_text is not None:
print ' %s ' % divider_text
print " "
for k in keys:
value = d[k]
if k == "description":
if value:
print ' %s
' % value
continue
if value.endswith(".png"):
value = (' '
% value)
print ' %s ' % (k, value)
print " "
prev_d = d
print ' '
def _main():
db = MHDB()
strees = db.get_skill_trees()
items = db.get_items(item_types=("Tool", "Book", "Consumable", "Ammo"))
print """
Poogie Translate
"""
print ''
#print PANEL
#print HEADER_START
#print '
Skill Trees '
#print ''
#print HEADER_NAV
print_header_nav("page-skilltrees")
print ''
mk_html_list(strees, ("name", "name_jp"), ("name",))
print '
'
print ' '
def item_divider_fn(d, prev_d):
prefix = _icon_prefix(d)
prev_prefix = _icon_prefix(prev_d)
if prefix != prev_prefix:
return prefix
return None
print ''
mk_html_list(items, ("icon_name", "name", "name_jp"),
("icon_name", "name"), divider_fn=item_divider_fn)
print '
'
print ''
ha_path = os.path.join(_pathfix.project_path, "db", "hunter_arts.json")
with open(ha_path) as f:
ha_list = json.load(f)
def ha_divider_fn(d, prev_d):
if prev_d is None:
return d["section"]
elif d["section"] != prev_d["section"]:
return d["section"]
return None
print ''
print_header_nav("page-hunterarts")
print '
'
mk_html_list(ha_list, ("name", "name_jp", "description"), None,
divider_fn=ha_divider_fn)
print '
'
print '
'
monster_path = os.path.join(_pathfix.project_path, "db",
"mhx_monster_list.json")
with open(monster_path) as f:
monster_list = json.load(f)
print ''
print_header_nav("page-monsters")
print '
'
mk_html_list(monster_list, ("name", "name_jp"), ("name",))
print '
'
print '
'
print """
"""
def _icon_prefix(d):
if d is None:
return ""
parts = d["icon_name"].split("-", 1)
return parts[0].replace(".png", "")
if __name__ == '__main__':
sys.stdout = get_utf8_writer(sys.stdout)
_main()