Compare commits

...

2 Commits
v0.3.1 ... main

Author SHA1 Message Date
bbe55592ec
prep v0.3.2 2023-03-24 15:37:36 +01:00
fe6c68d97b
add explicit handling for duplicate event names
when writing the translation file
2023-03-24 15:33:11 +01:00
3 changed files with 17 additions and 6 deletions

View File

@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
# [unreleased] # [unreleased]
# [v0.3.2]
- Added handling for duplicate event names when writing the event translation
file.
# [v0.3.1] # [v0.3.1]
- Sorted returnvalue export by raw returnvalue. - Sorted returnvalue export by raw returnvalue.

View File

@ -1,5 +1,5 @@
__version__ = "0.3.1" __version__ = "0.3.2"
VERSION_MAJOR = 0 VERSION_MAJOR = 0
VERSION_MINOR = 3 VERSION_MINOR = 3
VERSION_REVISION = 1 VERSION_REVISION = 2

View File

@ -274,10 +274,16 @@ def write_translation_source_file(
event_id = entry[0] event_id = entry[0]
event_value = entry[1] event_value = entry[1]
name = event_value.name name = event_value.name
if name not in lut: if name in lut:
definitions += f"const char *{name}_STRING " f'= "{name}";\n' _LOGGER.warning(
function += f" case ({event_id}):\n " f"return {name}_STRING;\n" "Duplicate name detected when generating event translation source file"
lut.update({name: event_value}) )
_LOGGER.warning(f"Name: {name}, Event Entry: {event_value}")
name = f"{name}_{event_id}"
_LOGGER.info(f"Created unique name {name}")
definitions += f"const char *{name}_STRING " f'= "{name}";\n'
function += f" case ({event_id}):\n " f"return {name}_STRING;\n"
lut.update({name: event_value})
function += ' default:\n return "UNKNOWN_EVENT";\n' function += ' default:\n return "UNKNOWN_EVENT";\n'
out.write( out.write(
f"/**\n * @brief Auto-generated event translation file. " f"/**\n * @brief Auto-generated event translation file. "