Skip to content

Commit 18a8e5c

Browse files
pdgendtkartben
authored andcommitted
scripts: logging: dictionary: log_parser_v1: Fix linter issues
Fix issues reported by ruff. Signed-off-by: Pieter De Gendt <[email protected]>
1 parent 03fbe7f commit 18a8e5c

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

.ruff-excludes.toml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -568,12 +568,6 @@
568568
"UP036", # https://docs.astral.sh/ruff/rules/outdated-version-block
569569
"UP038", # https://docs.astral.sh/ruff/rules/non-pep604-isinstance
570570
]
571-
"./scripts/logging/dictionary/dictionary_parser/log_parser_v1.py" = [
572-
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports
573-
"UP030", # https://docs.astral.sh/ruff/rules/format-literals
574-
"UP031", # https://docs.astral.sh/ruff/rules/printf-string-formatting
575-
"UP032", # https://docs.astral.sh/ruff/rules/f-string
576-
]
577571
"./scripts/logging/dictionary/dictionary_parser/log_parser_v3.py" = [
578572
"I001", # https://docs.astral.sh/ruff/rules/unsorted-imports
579573
]

scripts/logging/dictionary/dictionary_parser/log_parser_v1.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
import logging
1515
import math
1616
import struct
17+
1718
import colorama
1819
from colorama import Fore
1920

20-
from .log_parser import (LogParser, get_log_level_str_color, formalize_fmt_string)
2121
from .data_types import DataTypes
22-
22+
from .log_parser import LogParser, formalize_fmt_string, get_log_level_str_color
2323

2424
HEX_BYTES_IN_LINE = 16
2525

@@ -96,10 +96,7 @@ def __get_string(self, arg, arg_offset, string_tbl):
9696
str_idx = arg_offset + self.data_types.get_sizeof(DataTypes.PTR) * 2
9797
str_idx /= self.data_types.get_sizeof(DataTypes.INT)
9898

99-
if int(str_idx) not in string_tbl:
100-
ret = "<string@0x{0:x}>".format(arg)
101-
else:
102-
ret = string_tbl[int(str_idx)]
99+
ret = string_tbl.get(int(str_idx), f"<string@0x{arg:x}>")
103100

104101
return ret
105102

@@ -238,7 +235,7 @@ def print_hexdump(hex_data, prefix_len, color):
238235
chr_done = 0
239236

240237
for one_hex in hex_data:
241-
hex_vals += "%x " % one_hex
238+
hex_vals += f"{one_hex:x} "
242239
chr_vals += chr(one_hex)
243240
chr_done += 1
244241

0 commit comments

Comments
 (0)