Created
May 20, 2019 19:53
-
-
Save josh04/3d7164c6e287d7f28dc412e728e9afd6 to your computer and use it in GitHub Desktop.
_space_train simple codegen library functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def get_sheet(filename, sheetname): | |
with open(filename) as f: | |
item_database = json.load(f) | |
item_db_sheets = item_database['sheets'] | |
sheets = [sh for sh in item_db_sheets if sh['name'] == sheetname] | |
sheet = sheets[0] | |
sheet_lines = sheet['lines'] | |
sheet_types = sheet['columns'] | |
return sheet_lines, sheet_types | |
def open_header(filename, database, sys_headers, local_headers): | |
output_h = open(filename+'.hpp', 'w') | |
output_h.write("#ifndef "+filename.upper()+"_HPP \n") | |
output_h.write("#define "+filename.upper()+"_HPP \n") | |
output_h.write("// generated by codegen.py from "+database+"\n\n") | |
for h in sys_headers: | |
output_h.write("#include <"+h+"> \n") | |
for h in local_headers: | |
output_h.write("#include \""+h+"\" \n") | |
return output_h | |
def open_cpp(filename, database, sys_headers, local_headers): | |
output_h = open(filename+'.cpp', 'w') | |
output_h.write("// generated by codegen.py from "+database+"\n\n") | |
for h in sys_headers: | |
output_h.write("#include <"+h+"> \n") | |
for h in local_headers: | |
output_h.write("#include \""+h+"\" \n") | |
return output_h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment