diff options
author | Ross Burton <ross.burton@arm.com> | 2023-10-27 16:29:41 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-10-27 17:48:08 +0100 |
commit | d2c287db0739b249604cd1beaa03ec38512ba718 (patch) | |
tree | b64e2f3b65f5bf4849bd9fae3c2fc2fe3282789b /scripts | |
parent | 77c96e43090cbf485aec612cc2315b85e5635dda (diff) | |
download | openembedded-core-contrib-d2c287db0739b249604cd1beaa03ec38512ba718.tar.gz |
scripts/contrib/patchreview: consolidate imports
Move most imports to the top of the file.
Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/contrib/patchreview.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/contrib/patchreview.py b/scripts/contrib/patchreview.py index 36038d06d2..f95cadab0c 100755 --- a/scripts/contrib/patchreview.py +++ b/scripts/contrib/patchreview.py @@ -5,6 +5,15 @@ # SPDX-License-Identifier: GPL-2.0-only # +import argparse +import collections +import json +import os +import os.path +import pathlib +import re +import subprocess + # TODO # - option to just list all broken files # - test suite @@ -35,14 +44,12 @@ def blame_patch(patch): From a patch filename, return a list of "commit summary (author name <author email>)" strings representing the history. """ - import subprocess return subprocess.check_output(("git", "log", "--follow", "--find-renames", "--diff-filter=A", "--format=%s (%aN <%aE>)", "--", patch)).decode("utf-8").splitlines() def patchreview(patches): - import re, os.path # General pattern: start of line, optional whitespace, tag with optional # hyphen or spaces, maybe a colon, some whitespace, then the value, all case @@ -192,6 +199,7 @@ Patches in Pending state: %s""" % (total_patches, def histogram(results): from toolz import recipes, dicttoolz import math + counts = recipes.countby(lambda r: r.upstream_status, results.values()) bars = dicttoolz.valmap(lambda v: "#" * int(math.ceil(float(v) / len(results) * 100)), counts) for k in bars: @@ -226,8 +234,6 @@ def count_recipes(layers): return count if __name__ == "__main__": - import argparse, subprocess, os, pathlib - args = argparse.ArgumentParser(description="Patch Review Tool") args.add_argument("-b", "--blame", action="store_true", help="show blame for malformed patches") args.add_argument("-v", "--verbose", action="store_true", help="show per-patch results") @@ -243,7 +249,6 @@ if __name__ == "__main__": analyse(results, want_blame=args.blame, verbose=args.verbose) if args.json: - import json, os.path, collections if os.path.isfile(args.json): data = json.load(open(args.json)) else: |