1
This commit is contained in:
parent
f86d455b60
commit
fe9c58036c
1968
scripts/md_csv/dict.json
Normal file
1968
scripts/md_csv/dict.json
Normal file
File diff suppressed because it is too large
Load Diff
18
scripts/md_csv/dict2php.py
Normal file
18
scripts/md_csv/dict2php.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
|
dict_file = open('/usr/share/nginx/html/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')
|
@ -10,6 +10,7 @@ TOKEN_REGEX2 = r"""(?:\|\s*)([^\s]*)(?:\s*)(?:\|\s*)([^\s]*)(?:\s*)(?:\|\s*)([^\
|
|||||||
def md2csv(mdfile):
|
def md2csv(mdfile):
|
||||||
state = 0
|
state = 0
|
||||||
log_dict = {}
|
log_dict = {}
|
||||||
|
log_dict['__keys__'] = []
|
||||||
curr_node = None
|
curr_node = None
|
||||||
for line in open(mdfile).readlines():
|
for line in open(mdfile).readlines():
|
||||||
match = re.match(TOKEN_REGEX, line)
|
match = re.match(TOKEN_REGEX, line)
|
||||||
@ -18,23 +19,27 @@ def md2csv(mdfile):
|
|||||||
state = 1
|
state = 1
|
||||||
assert((logclass1 + '-' + logclass2) not in log_dict)
|
assert((logclass1 + '-' + logclass2) not in log_dict)
|
||||||
curr_node = {}
|
curr_node = {}
|
||||||
log_dict[logclass1 + '-' + logclass2] = curr_node
|
curr_node['__keys__'] = []
|
||||||
# print('')
|
log_key = logclass1 + '-' + logclass2
|
||||||
# print(logclass1, logclass2, title)
|
log_dict[log_key] = curr_node
|
||||||
|
log_dict['__keys__'].append(log_key)
|
||||||
continue
|
continue
|
||||||
match2 = re.match(TOKEN_REGEX2, line)
|
match2 = re.match(TOKEN_REGEX2, line)
|
||||||
if match2 and state == 1:
|
if match2 and state == 1:
|
||||||
field1, field2, field3, field4 = match2.groups()
|
field1, field2, field3, field4 = match2.groups()
|
||||||
if field1[0] != '-' and field1 != '字段':
|
if field1[0] != '-' and field1 != '字段':
|
||||||
curr_node[field1.replace('\\', '')] = {
|
field_name = field1.replace('\\', '')
|
||||||
'short_name': field1.replace('\\', ''),
|
en_name = field2.replace('\\', '')
|
||||||
'en_name': field2.replace('\\', ''),
|
curr_node[field_name] = {
|
||||||
|
'short_name': field_name,
|
||||||
|
'en_name': en_name,
|
||||||
'desc': field4
|
'desc': field4
|
||||||
}
|
}
|
||||||
curr_node[field2.replace('\\', '')] = curr_node[field1.replace('\\', '')]
|
curr_node['__keys__'].append(field_name)
|
||||||
# print(field1 + ',' + field2 + ',' + field3 + ',' + field4)
|
if not (en_name in curr_node):
|
||||||
|
curr_node['__keys__'].append(en_name)
|
||||||
|
curr_node[en_name] = curr_node[field_name]
|
||||||
#end for
|
#end for
|
||||||
# pprint.pprint(log_dict)
|
|
||||||
print(json.dumps(log_dict, sort_keys=True, indent=4, separators=(',', ': ')))
|
print(json.dumps(log_dict, sort_keys=True, indent=4, separators=(',', ': ')))
|
||||||
|
|
||||||
md2csv('/root/opensource/doc/api说明/gamelog.md')
|
md2csv('/root/opensource/doc/api说明/gamelog.md')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user