# -*- coding: utf-8 -*-
import os
import json

dict_file = open('/var/data/gamelog/webapp/bootstrap/dict.php', 'w')
dict_file.write('<?php\n\n')
dict_file.write('    $log_dict = array(\n')

log_dict = json.loads(open('dict.json', 'r').read())
for key in log_dict['__keys__']:
    dict_file.write("        \"%s\" => array(\n" % key)
    node = log_dict[key]
    for fieldname in node['__keys__']:
        en_name = node[fieldname]['en_name']
        dict_file.write("            \"%s\" => \"%s\",\n" % (fieldname, en_name))
    dict_file.write("        ),\n")

dict_file.write('    );\n')
dict_file.write('    return $log_dict;\n')
