diff options
author | Simon Glass <sjg@chromium.org> | 2023-11-04 10:25:22 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2023-11-14 20:04:00 -0700 |
commit | 21229c921bf62a5480e887d71ba13ac482282870 (patch) | |
tree | 512a03f7f24435b25665a609462d119833b1f120 | |
parent | e296a3c73d22bf95f38318a8dac2dc0177a3b145 (diff) | |
download | u-boot-21229c921bf62a5480e887d71ba13ac482282870.zip u-boot-21229c921bf62a5480e887d71ba13ac482282870.tar.gz u-boot-21229c921bf62a5480e887d71ba13ac482282870.tar.bz2 |
patman: Correct easy pylint warnings in __main__
Tidy up the code a little to reduce the number of pylint warnings.
Signed-off-by: Simon Glass <sjg@chromium.org>
-rwxr-xr-x | tools/patman/__main__.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/tools/patman/__main__.py b/tools/patman/__main__.py index 8785029..3ca858c 100755 --- a/tools/patman/__main__.py +++ b/tools/patman/__main__.py @@ -16,10 +16,10 @@ import re import sys import traceback -if __name__ == "__main__": - # Allow 'from patman import xxx to work' - our_path = os.path.dirname(os.path.realpath(__file__)) - sys.path.append(os.path.join(our_path, '..')) +# Allow 'from patman import xxx to work' +# pylint: disable=C0413 +our_path = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(our_path, '..')) # Our modules from patman import cmdline @@ -43,6 +43,7 @@ def run_patman(): # Run our meagre tests if args.cmd == 'test': + # pylint: disable=C0415 from patman import func_test from patman import test_checkpatch @@ -58,16 +59,15 @@ def run_patman(): # Called from git with a patch filename as argument # Printout a list of additional CC recipients for this patch if args.cc_cmd: - fd = open(args.cc_cmd, 'r') - re_line = re.compile('(\S*) (.*)') - for line in fd.readlines(): - match = re_line.match(line) - if match and match.group(1) == args.patchfiles[0]: - for cc in match.group(2).split('\0'): - cc = cc.strip() - if cc: - print(cc) - fd.close() + re_line = re.compile(r'(\S*) (.*)') + with open(args.cc_cmd, 'r', encoding='utf-8') as inf: + for line in inf.readlines(): + match = re_line.match(line) + if match and match.group(1) == args.patchfiles[0]: + for cca in match.group(2).split('\0'): + cca = cca.strip() + if cca: + print(cca) elif args.full_help: with importlib.resources.path('patman', 'README.rst') as readme: @@ -85,8 +85,8 @@ def run_patman(): control.patchwork_status(args.branch, args.count, args.start, args.end, args.dest_branch, args.force, args.show_comments, args.patchwork_url) - except Exception as e: - terminal.tprint('patman: %s: %s' % (type(e).__name__, e), + except Exception as exc: + terminal.tprint(f'patman: {type(exc).__name__}: {exc}', colour=terminal.Color.RED) if args.debug: print() |