update output file format

This commit is contained in:
Robin Müller 2022-02-03 17:13:49 +01:00
parent 636670f7a0
commit 502f7d4f5e
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -247,15 +247,15 @@ def write_translation_source_file(
outputfile = open(filename, "w")
definitions = ""
function = "const char * translateEvents(Event event) {\n\tswitch( (event & 0xffff) ) {\n"
function = "const char * translateEvents(Event event) {\n switch( (event & 0xffff) ) {\n"
for entry in event_list:
event_id = entry[0]
event_value = entry[1]
definitions += \
f"const char *{event_value[EVENT_ENTRY_NAME_IDX]}_STRING " \
f"= \"{event_value[EVENT_ENTRY_NAME_IDX]}\";\n"
function += f"\tcase({event_id}):\n\t\treturn {event_value[EVENT_ENTRY_NAME_IDX]}_STRING;\n"
function += '\tdefault:\n\t\treturn "UNKNOWN_EVENT";\n'
function += f" case({event_id}):\n return {event_value[EVENT_ENTRY_NAME_IDX]}_STRING;\n"
function += ' default:\n return "UNKNOWN_EVENT";\n'
outputfile.write(
f"/**\n * @brief Auto-generated event translation file. "
f"Contains {len(event_list)} translations.\n"
@ -263,7 +263,7 @@ def write_translation_source_file(
f" * Generated on: {date_string}\n */\n"
)
outputfile.write("#include \"translateEvents.h\"\n\n")
outputfile.write(definitions + "\n" + function + "\t}\n\treturn 0;\n}\n")
outputfile.write(definitions + "\n" + function + " }\n return 0;\n}\n")
outputfile.close()