scripts: logging: dictionary: log_parser: Fix linter issues

Fix issues reported by ruff.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This commit is contained in:
Pieter De Gendt 2025-05-25 12:08:42 +02:00 committed by Benjamin Cabé
commit ffeca1695a
2 changed files with 6 additions and 13 deletions

View file

@ -568,10 +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/log_parser.py" = [
"SIM115", # https://docs.astral.sh/ruff/rules/open-file-with-context-handler
"UP015", # https://docs.astral.sh/ruff/rules/redundant-open-modes
]
"./scripts/make_bugs_pickle.py" = [
"UP006", # https://docs.astral.sh/ruff/rules/non-pep585-annotation
"UP035", # https://docs.astral.sh/ruff/rules/deprecated-import

View file

@ -57,7 +57,7 @@ def read_log_file(args):
else:
hexdata = ''
with open(args.logfile, "r", encoding="iso-8859-1") as hexfile:
with open(args.logfile, encoding="iso-8859-1") as hexfile:
for line in hexfile.readlines():
hexdata += line.strip()
@ -90,14 +90,11 @@ def read_log_file(args):
logdata = binascii.unhexlify(hexdata[:idx])
else:
logfile = open(args.logfile, "rb")
if not logfile:
logger.error("ERROR: Cannot open binary log data file: %s, exiting...", args.logfile)
sys.exit(1)
logdata = logfile.read()
logfile.close()
with open(args.logfile, "rb") as logfile:
if not logfile:
logger.error(f"ERROR: Cannot open binary log data file: {args.logfile}, exiting...")
sys.exit(1)
logdata = logfile.read()
return logdata