Compare commits

...

3 Commits
v0.3.0 ... 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
cada155b8e
prep v0.3.1 2023-03-14 15:24:55 +01:00
4 changed files with 28 additions and 12 deletions

View File

@ -8,6 +8,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
# [unreleased]
# [v0.3.2]
- Added handling for duplicate event names when writing the event translation
file.
# [v0.3.1]
- Sorted returnvalue export by raw returnvalue.
# [v0.3.0]
- Description parser is now more generic and parses a list of meta informations.

View File

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

View File

@ -274,10 +274,16 @@ def write_translation_source_file(
event_id = entry[0]
event_value = entry[1]
name = event_value.name
if name not in lut:
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})
if name in lut:
_LOGGER.warning(
"Duplicate name detected when generating event translation source file"
)
_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'
out.write(
f"/**\n * @brief Auto-generated event translation file. "

View File

@ -461,16 +461,17 @@ class ReturnValueParser(FileParser):
f"Full ID (hex){column_sep} Name{column_sep} Description{column_sep} "
f"Unique ID{column_sep} Subsytem Name{column_sep} File Path\n"
)
for entry in list_of_entries.items():
for k, entry in sorted(list_of_entries.items()):
# entry: tuple
if column_sep == ";":
entry[1].description = entry[1].description.replace(";", ",")
entry.description = entry.description.replace(";", ",")
elif column_sep == ",":
# Quote the description
entry[1].description = f'"{entry[1].description}"'
entry.description = f'"{entry.description}"'
out.write(
f"{entry[0]:#06x}{column_sep}{entry[1].name}{column_sep}{entry[1].description}"
f"{column_sep}{entry[1].unique_id}{column_sep}{entry[1].subsystem_name}"
f"{column_sep}{entry[1].file_name.as_posix()}\n"
f"{k:#06x}{column_sep}{entry.name}{column_sep}{entry.description}"
f"{column_sep}{entry.unique_id}{column_sep}{entry.subsystem_name}"
f"{column_sep}{entry.file_name.as_posix()}\n"
)
def build_checked_string(