Browse Source

scripts: logging: dictionary: log_parser: Fix linter issues

Fix issues reported by ruff.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
pull/91278/head
Pieter De Gendt 1 month ago committed by Benjamin Cabé
parent
commit
ffeca1695a
  1. 4
      .ruff-excludes.toml
  2. 15
      scripts/logging/dictionary/log_parser.py

4
.ruff-excludes.toml

@ -568,10 +568,6 @@ @@ -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

15
scripts/logging/dictionary/log_parser.py

@ -57,7 +57,7 @@ def read_log_file(args): @@ -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): @@ -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

Loading…
Cancel
Save