From 18a8e5c5b536b5264caa926d486b064b659ca21f Mon Sep 17 00:00:00 2001 From: Pieter De Gendt Date: Sun, 25 May 2025 12:02:26 +0200 Subject: [PATCH] scripts: logging: dictionary: log_parser_v1: Fix linter issues Fix issues reported by ruff. Signed-off-by: Pieter De Gendt --- .ruff-excludes.toml | 6 ------ .../dictionary/dictionary_parser/log_parser_v1.py | 11 ++++------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/.ruff-excludes.toml b/.ruff-excludes.toml index 2505b88549b..9f23546a57b 100644 --- a/.ruff-excludes.toml +++ b/.ruff-excludes.toml @@ -568,12 +568,6 @@ "UP036", # https://docs.astral.sh/ruff/rules/outdated-version-block "UP038", # https://docs.astral.sh/ruff/rules/non-pep604-isinstance ] -"./scripts/logging/dictionary/dictionary_parser/log_parser_v1.py" = [ - "I001", # https://docs.astral.sh/ruff/rules/unsorted-imports - "UP030", # https://docs.astral.sh/ruff/rules/format-literals - "UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting - "UP032", # https://docs.astral.sh/ruff/rules/f-string -] "./scripts/logging/dictionary/dictionary_parser/log_parser_v3.py" = [ "I001", # https://docs.astral.sh/ruff/rules/unsorted-imports ] diff --git a/scripts/logging/dictionary/dictionary_parser/log_parser_v1.py b/scripts/logging/dictionary/dictionary_parser/log_parser_v1.py index 92eb7cc9c89..e73f1cd36db 100644 --- a/scripts/logging/dictionary/dictionary_parser/log_parser_v1.py +++ b/scripts/logging/dictionary/dictionary_parser/log_parser_v1.py @@ -14,12 +14,12 @@ version 1 databases. import logging import math import struct + import colorama from colorama import Fore -from .log_parser import (LogParser, get_log_level_str_color, formalize_fmt_string) from .data_types import DataTypes - +from .log_parser import LogParser, formalize_fmt_string, get_log_level_str_color HEX_BYTES_IN_LINE = 16 @@ -96,10 +96,7 @@ class LogParserV1(LogParser): str_idx = arg_offset + self.data_types.get_sizeof(DataTypes.PTR) * 2 str_idx /= self.data_types.get_sizeof(DataTypes.INT) - if int(str_idx) not in string_tbl: - ret = "".format(arg) - else: - ret = string_tbl[int(str_idx)] + ret = string_tbl.get(int(str_idx), f"") return ret @@ -238,7 +235,7 @@ class LogParserV1(LogParser): chr_done = 0 for one_hex in hex_data: - hex_vals += "%x " % one_hex + hex_vals += f"{one_hex:x} " chr_vals += chr(one_hex) chr_done += 1