From ac9f682344c9065c7e6259020c616166785263de Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Tue, 7 Jul 2020 16:03:23 +0200 Subject: [PATCH] Fix flake8 issues 1) Drop unused import (fileinput) Fixes: | F401 'fileinput' imported but unused 2) Quoting from https://www.flake8rules.com/rules/E722.html: | A bare except: clause will catch SystemExit and KeyboardInterrupt | exceptions, making it harder to interrupt a program with Control-C, and | can disguise other problems. If you want to catch all exceptions that | signal program errors, use except Exception: (bare except is equivalent | to except BaseException:). Fixes: | E722 do not use bare except, specify exception instead 3) Quoting from https://www.flake8rules.com/rules/E713.html: | Tests for membership should use the form x not in the_list rather than | not x in the_list. The former example is simply more readable. Fixes: | E713 test for membership should be 'not in' --- grml-x | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/grml-x b/grml-x index 2aefadc..d8b9c8b 100755 --- a/grml-x +++ b/grml-x @@ -9,7 +9,6 @@ # License: This file is licensed under the GPL v2. ############################################################################### -import fileinput import os import subprocess import sys @@ -75,7 +74,7 @@ def build_bootparams(): f = open(os.path.join(root, name)) lines.extend(f.readlines()) f.close() - except: + except Exception: print("W: Error while getting bootparams from %s" % p) f = open("/proc/cmdline") @@ -144,7 +143,7 @@ def check_old_xorg_conf(filename, overwrite): f = open(filename, "r") lines = f.readlines() f.close() - return not XORG_CONF_HEADER in lines + return XORG_CONF_HEADER not in lines except IOError: return False -- 2.1.4