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 2 months ago committed by Benjamin Cabé
parent
commit
ffeca1695a
  1. 4
      .ruff-excludes.toml
  2. 9
      scripts/logging/dictionary/log_parser.py

4
.ruff-excludes.toml

@ -568,10 +568,6 @@
"UP036", # https://docs.astral.sh/ruff/rules/outdated-version-block "UP036", # https://docs.astral.sh/ruff/rules/outdated-version-block
"UP038", # https://docs.astral.sh/ruff/rules/non-pep604-isinstance "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" = [ "./scripts/make_bugs_pickle.py" = [
"UP006", # https://docs.astral.sh/ruff/rules/non-pep585-annotation "UP006", # https://docs.astral.sh/ruff/rules/non-pep585-annotation
"UP035", # https://docs.astral.sh/ruff/rules/deprecated-import "UP035", # https://docs.astral.sh/ruff/rules/deprecated-import

9
scripts/logging/dictionary/log_parser.py

@ -57,7 +57,7 @@ def read_log_file(args):
else: else:
hexdata = '' 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(): for line in hexfile.readlines():
hexdata += line.strip() hexdata += line.strip()
@ -90,15 +90,12 @@ def read_log_file(args):
logdata = binascii.unhexlify(hexdata[:idx]) logdata = binascii.unhexlify(hexdata[:idx])
else: else:
logfile = open(args.logfile, "rb") with open(args.logfile, "rb") as logfile:
if not logfile: if not logfile:
logger.error("ERROR: Cannot open binary log data file: %s, exiting...", args.logfile) logger.error(f"ERROR: Cannot open binary log data file: {args.logfile}, exiting...")
sys.exit(1) sys.exit(1)
logdata = logfile.read() logdata = logfile.read()
logfile.close()
return logdata return logdata
def main(): def main():

Loading…
Cancel
Save