improved csv format
This commit is contained in:
parent
a2e0c4f98e
commit
a5dee6e417
@ -239,19 +239,22 @@ class EventParser(FileParser):
|
||||
return description
|
||||
|
||||
|
||||
def export_to_file(filename: Path, event_list: EventDictT, file_separator: str):
|
||||
file = open(filename, "w")
|
||||
fsep = file_separator
|
||||
for entry in event_list.items():
|
||||
event_id = int(entry[0])
|
||||
event_value = entry[1]
|
||||
event_id_as_hex = f"{event_id:#06x}"
|
||||
file.write(
|
||||
f"{event_id}{fsep}{event_id_as_hex}{fsep}{event_value.name}{fsep}"
|
||||
f"{event_value.severity}{fsep}{event_value.description}"
|
||||
f"{fsep}{event_value.file_name.as_posix()}\n"
|
||||
def export_to_csv(filename: Path, event_list: EventDictT, col_sep: str):
|
||||
with open(filename, "w") as out:
|
||||
fsep = col_sep
|
||||
out.write(
|
||||
f"Event ID (dec){col_sep} Event ID (hex){col_sep} Name{col_sep} "
|
||||
f"Severity{col_sep} Description{col_sep} File Path\n"
|
||||
)
|
||||
file.close()
|
||||
for entry in event_list.items():
|
||||
event_id = int(entry[0])
|
||||
event_value = entry[1]
|
||||
event_id_as_hex = f"{event_id:#06x}"
|
||||
out.write(
|
||||
f"{event_id}{fsep}{event_id_as_hex}{fsep}{event_value.name}{fsep}"
|
||||
f"{event_value.severity}{fsep}{event_value.description}"
|
||||
f"{fsep}{event_value.file_name.as_posix()}\n"
|
||||
)
|
||||
|
||||
|
||||
def write_translation_source_file(
|
||||
@ -297,9 +300,7 @@ def handle_csv_export(file_name: Path, event_list: EventDictT, file_separator: s
|
||||
Generates the CSV in the same directory as the .py file and copes the CSV to another
|
||||
directory if specified.
|
||||
"""
|
||||
export_to_file(
|
||||
filename=file_name, event_list=event_list, file_separator=file_separator
|
||||
)
|
||||
export_to_csv(filename=file_name, event_list=event_list, col_sep=file_separator)
|
||||
|
||||
|
||||
def handle_cpp_export(
|
||||
|
@ -405,15 +405,23 @@ class ReturnValueParser(FileParser):
|
||||
self.mib_table = self.return_value_dict
|
||||
|
||||
@staticmethod
|
||||
def export_to_file(filename: Path, list_of_entries: RetvalDictT, file_sep: str):
|
||||
file = open(filename, "w")
|
||||
for entry in list_of_entries.items():
|
||||
file.write(
|
||||
f"{entry[0]:#06x}{file_sep}{entry[1].name}{file_sep}{entry[1].description}"
|
||||
f"{file_sep}{entry[1].unique_id}{file_sep}{entry[1].subsystem_name}{file_sep}"
|
||||
f"{entry[1].file_name.as_posix()}\n"
|
||||
def export_to_csv(filename: Path, list_of_entries: RetvalDictT, column_sep: str):
|
||||
with open(filename, "w") as out:
|
||||
out.write(
|
||||
f"Full ID (hex){column_sep} Name{column_sep} Description{column_sep} "
|
||||
f"Unique ID{column_sep} Subsytem Name{column_sep} File Path\n"
|
||||
)
|
||||
file.close()
|
||||
for entry in list_of_entries.items():
|
||||
if column_sep == ";":
|
||||
entry[1].description = entry[1].description.replace(";", ",")
|
||||
elif column_sep == ",":
|
||||
# Quote the description
|
||||
entry[1].description = f'"{entry[1].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"
|
||||
)
|
||||
|
||||
def build_checked_string(
|
||||
self,
|
||||
|
Loading…
x
Reference in New Issue
Block a user