import re SCR_CMD_PAT = re.compile(r"\tscript_cmd_table_entry (\w+)\s+\w+,\s+[\w=]+\s+@( 0x[0-9a-f]+)") def main(): output = [ "//", "// DO NOT MODIFY THIS FILE! It is auto-generated by tools/misc/make_scr_cmd_constants.py", "//", "#ifndef GUARD_SCR_CMD_CONSTANTS_H", "#define GUARD_SCR_CMD_CONSTANTS_H\n", ] with open("data/script_cmd_table.inc", "r") as f: for line in f.readlines(): if match := re.match(SCR_CMD_PAT, line): new_line = "#define " + match.group(1) + match.group(2) output.append(new_line) output.append("\n#endif // GUARD_SCR_CMD_CONSTANTS_H\n") with open("include/constants/script_commands.h", "w+") as f: f.write('\n'.join(output)) if __name__ == "__main__": main()