diff options
author | Klement Sekera <klement.sekera@gmail.com> | 2022-04-26 19:02:15 +0200 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2022-05-10 18:52:08 +0000 |
commit | d9b0c6fbf7aa5bd9af84264105b39c82028a4a29 (patch) | |
tree | 4f786cfd8ebc2443cb11e11b74c8657204068898 /extras/deprecated/perfmon/intel_json_to_c.py | |
parent | f90348bcb4afd0af2611cefc43b17ef3042b511c (diff) |
tests: replace pycodestyle with black
Drop pycodestyle for code style checking in favor of black. Black is
much faster, stable PEP8 compliant code style checker offering also
automatic formatting. It aims to be very stable and produce smallest
diffs. It's used by many small and big projects.
Running checkstyle with black takes a few seconds with a terse output.
Thus, test-checkstyle-diff is no longer necessary.
Expand scope of checkstyle to all python files in the repo, replacing
test-checkstyle with checkstyle-python.
Also, fixstyle-python is now available for automatic style formatting.
Note: python virtualenv has been consolidated in test/Makefile,
test/requirements*.txt which will eventually be moved to a central
location. This is required to simply the automated generation of
docker executor images in the CI.
Type: improvement
Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8
Signed-off-by: Klement Sekera <klement.sekera@gmail.com>
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'extras/deprecated/perfmon/intel_json_to_c.py')
-rwxr-xr-x | extras/deprecated/perfmon/intel_json_to_c.py | 64 |
1 files changed, 38 insertions, 26 deletions
diff --git a/extras/deprecated/perfmon/intel_json_to_c.py b/extras/deprecated/perfmon/intel_json_to_c.py index 6a625ac2c33..4389c86fc38 100755 --- a/extras/deprecated/perfmon/intel_json_to_c.py +++ b/extras/deprecated/perfmon/intel_json_to_c.py @@ -4,48 +4,58 @@ import json, argparse p = argparse.ArgumentParser() -p.add_argument('-i', '--input', action="store", - help="input JSON file name", required = True) - -p.add_argument('-o', '--output', action="store", - help="output C file name", required = True) - -p.add_argument('-m', '--model', action="append", - help="CPU model in format: model[,stepping0]", - required = True) +p.add_argument( + "-i", "--input", action="store", help="input JSON file name", required=True +) + +p.add_argument( + "-o", "--output", action="store", help="output C file name", required=True +) + +p.add_argument( + "-m", + "--model", + action="append", + help="CPU model in format: model[,stepping0]", + required=True, +) r = p.parse_args() -with open(r.input, 'r') as fp: +with open(r.input, "r") as fp: objects = json.load(fp) -c = open(r.output, 'w') +c = open(r.output, "w") -c.write (""" +c.write( + """ #include <perfmon/perfmon_intel.h> static perfmon_intel_pmc_cpu_model_t cpu_model_table[] = { -""") +""" +) for v in r.model: if "," in v: - (m, s) = v.split(",") + (m, s) = v.split(",") m = int(m, 0) s = int(s, 0) - c.write (" {}0x{:02X}, 0x{:02X}, 1{},\n".format("{", m, s, "}")) + c.write(" {}0x{:02X}, 0x{:02X}, 1{},\n".format("{", m, s, "}")) else: m = int(v, 0) - c.write (" {}0x{:02X}, 0x00, 0{},\n".format("{", m, "}")) -c.write (""" + c.write(" {}0x{:02X}, 0x00, 0{},\n".format("{", m, "}")) +c.write( + """ }; static perfmon_intel_pmc_event_t event_table[] = { -""") +""" +) for obj in objects: MSRIndex = obj["MSRIndex"] if MSRIndex != "0": - continue + continue EventCode = obj["EventCode"] UMask = obj["UMask"] @@ -53,20 +63,22 @@ for obj in objects: if "," in EventCode: continue - c.write (" {\n") - c.write (" .event_code = {}{}{},\n".format("{", EventCode, "}")) - c.write (" .umask = {},\n".format(UMask)) - c.write (" .event_name = \"{}\",\n".format(EventName)) - c.write (" },\n") + c.write(" {\n") + c.write(" .event_code = {}{}{},\n".format("{", EventCode, "}")) + c.write(" .umask = {},\n".format(UMask)) + c.write(' .event_name = "{}",\n'.format(EventName)) + c.write(" },\n") -c.write (""" { +c.write( + """ { .event_name = 0, }, }; PERFMON_REGISTER_INTEL_PMC (cpu_model_table, event_table); -""") +""" +) c.close() |