From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: sireesha.nakkala@toshiba-tsip.com Date: Wed, 20 Apr 2022 15:41:40 +0530 Message-Id: <20220420101140.27182-9-sireesha.nakkala@toshiba-tsip.com> In-Reply-To: <20220420101140.27182-1-sireesha.nakkala@toshiba-tsip.com> References: <20220420101140.27182-1-sireesha.nakkala@toshiba-tsip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Fuego] [PATCH 8/8] python2to3: use list() for dict.keys(), dict.values() and dict.items() List-Id: Mailing list for the Fuego test framework List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tim.bird@sony.com Cc: kazuhiro3.hayashi@toshiba.co.jp, fuego@lists.linuxfoundation.org, dinesh.kumar@toshiba-tsip.com, Shivanand Kunijadar , sireesha From: sireesha python3 returns dict_keys type for dict.keys() which doesn't support indexing where as python2 returns a list type which does. Use list() on the output of dict.keys() to make the code work with python3. Signed-off-by: sireesha Signed-off-by: Shivanand Kunijadar --- scripts/check-dependencies | 2 +- scripts/ftc | 10 +++++----- scripts/jdiff | 4 ++-- scripts/ovgen.py | 2 +- scripts/parser/common.py | 10 +++++----- scripts/parser/prepare_chart_data.py | 16 ++++++++-------- tests/Functional.LTP/ltp_process.py | 2 +- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/scripts/check-dependencies b/scripts/check-dependencies index 72a5f31..583012e 100755 --- a/scripts/check-dependencies +++ b/scripts/check-dependencies @@ -218,7 +218,7 @@ def main(): # print the testcases skipped # this is the main output from the program - testcases_to_skip = reasons.keys() + testcases_to_skip = list(reasons.keys()) testcases_to_skip.sort() for testcase in testcases_to_skip: print(testcase) diff --git a/scripts/ftc b/scripts/ftc index 3723e7e..f32d9cc 100755 --- a/scripts/ftc +++ b/scripts/ftc @@ -905,7 +905,7 @@ class test_class: } def __init__(self, conf, test_dict, test_flags={}): merged_defaults = dict(self.DEFAULT_DEFAULTS) - for key, value in test_flags.items(): + for key, value in list(test_flags.items()): merged_defaults[key] = value self.name = str(test_dict["testName"]) self.test_type = self.name.split(".")[0] @@ -1642,7 +1642,7 @@ def parse_testplan(conf, plan, test_dict): test_flags['postcleanup'] = plan['default_postcleanup'] # override with testplan per-test flags - for key, value in plan_test_dict.items(): + for key, value in list(plan_test_dict.items()): if key == "testName": test_dict[key] = value continue @@ -2584,7 +2584,7 @@ def parse_where(where_string): def filter_runs(run_map, where_list): new_run_list = [] - for run_id, run in run_map.items(): + for run_id, run in list(run_map.items()): match = True for where in where_list: if not where.match(run): @@ -2915,7 +2915,7 @@ def pts_set_style(ws): for cell in row: if cell.value: dims[cell.column] = max((dims.get(cell.column, 0), len(str(cell.value)) + 2)) - for col, value in dims.items(): + for col, value in list(dims.items()): ws.column_dimensions[col].width = value @@ -4767,7 +4767,7 @@ def do_run_test(conf, options): test_spec_data['specs'][test.spec][key] = dyn_vars[key] # track what variables where modified - test_spec_data['specs'][test.spec]['dyn_vars'] = dyn_vars.keys() + test_spec_data['specs'][test.spec]['dyn_vars'] = list(dyn_vars.keys()) dvar("test_spec_data") if os.path.isdir(build_data.test_logdir): diff --git a/scripts/jdiff b/scripts/jdiff index b267afd..39ea1db 100755 --- a/scripts/jdiff +++ b/scripts/jdiff @@ -94,9 +94,9 @@ def diff_list(prefix, l1, l2): def diff_map(prefix, m1, m2): dprint("in diff_map, m1=%s, m2=%s" % (m1, m2)) - l1s = m1.keys() + l1s = list(m1.keys()) l1s.sort() - l2s = m2.keys() + l2s = list(m2.keys()) l2s.sort() dprint("in diff_map, l1s=%s, l2s=%s" % (l1s, l2s)) diff --git a/scripts/ovgen.py b/scripts/ovgen.py index 1386ff5..f47a384 100755 --- a/scripts/ovgen.py +++ b/scripts/ovgen.py @@ -453,7 +453,7 @@ def parseSpec(logdir, testdir, testspec): test_spec_data = json.load(f) except: error_out("Error parsing spec file %s" % specpath) - for key in test_spec_data['specs'].keys(): + for key in list(test_spec_data['specs'].keys()): if key != testspec: del test_spec_data['specs'][key] debug_print("test spec data:" + str(test_spec_data)) diff --git a/scripts/parser/common.py b/scripts/parser/common.py index 8c307f1..a3d71ca 100644 --- a/scripts/parser/common.py +++ b/scripts/parser/common.py @@ -178,7 +178,7 @@ def add_results(results, run_data): dprint("in add_results") if not results: return - for test_case_id in results.keys(): + for test_case_id in list(results.keys()): test_case = get_test_case(test_case_id, run_data) if not test_case: continue @@ -516,7 +516,7 @@ def apply_criteria(run_data, criteria_data): def create_default_ref(results): dprint("in create_default_ref") ref = {'test_sets': []} - for test_case_id in results.keys(): + for test_case_id in list(results.keys()): test_set_name, test_case_name = split_test_id(test_case_id) item = results[test_case_id] if isinstance(item, list): @@ -553,7 +553,7 @@ def name_compare(a, b): def dump_ordered_data(data, indent=""): if type(data)==type({}): print("%s{" % indent) - keylist = data.keys() + keylist = list(data.keys()) keylist.sort() for key in keylist: print('%s "%s":' % (indent+" ", key), @@ -734,7 +734,7 @@ def process_data(ref_section_pat, test_results, plot_type, label): test_name = TESTDIR.split(".")[1] # convert old-style cur_dict into measurements structure - for (old_id, value) in test_results.items(): + for (old_id, value) in list(test_results.items()): ts_name, tc_name, measure = split_old_id(old_id) test_case_id = "%s.%s" % (ts_name, tc_name) new_measure = {"name":measure, "measure": float(value)} @@ -819,7 +819,7 @@ def split_output_per_testcase (regex_string, measurements, info_follows_regex=0) fd.close() # note that measurements is an OrderedDict, so keys comes out ordered - testcase_names = measurements.keys() + testcase_names = list(measurements.keys()) if info_follows_regex: # You can have stuff before the first testcase delimiter that diff --git a/scripts/parser/prepare_chart_data.py b/scripts/parser/prepare_chart_data.py index d85315e..61b55f5 100644 --- a/scripts/parser/prepare_chart_data.py +++ b/scripts/parser/prepare_chart_data.py @@ -386,7 +386,7 @@ def make_measure_plots(test_name, chart_config, entries): point = [entry.build_number, value] series_map[ref_series_key]["data"].append(point) - flot_data = series_map.values() + flot_data = list(series_map.values()) flot_data.sort(key=itemgetter('label')) flot_options = { @@ -425,7 +425,7 @@ def make_measure_tables(test_name, chart_config, entries): for entry in entries: bsp_key = entry.board + "." + entry.spec + "." + entry.kernel bsp_map[bsp_key] = ((entry.board, entry.spec, entry.kernel)) - bsp_list = bsp_map.values() + bsp_list = list(bsp_map.values()) # now make a chart for each one: for board, spec, kver in bsp_list: @@ -473,7 +473,7 @@ def make_measure_tables(test_name, chart_config, entries): else: build_num_map[entry.build_number][3] += 1 - bn_list = build_num_map.keys() + bn_list = list(build_num_map.keys()) bn_list.sort() # FIXTHIS - should read col_limit from chart_config @@ -506,7 +506,7 @@ def make_measure_tables(test_name, chart_config, entries): html += row # one row per test case - tg_list = result_map.keys() + tg_list = list(result_map.keys()) tg_list.sort(key=functools.cmp_to_key(cmp_alpha_num)) for tg in tg_list: @@ -617,7 +617,7 @@ def make_testcase_table(test_name, chart_config, entries): for entry in entries: bts_key = entry.board + "." + entry.test_set bts_map[bts_key] = ((entry.board, entry.test_set)) - bts_list = bts_map.values() + bts_list = list(bts_map.values()) # now make a chart for each one: for board, ts in bts_list: @@ -697,7 +697,7 @@ def make_testcase_table(test_name, chart_config, entries): else: build_num_map[entry.build_number][3] += 1 - bn_list = build_num_map.keys() + bn_list = list(build_num_map.keys()) bn_list.sort() # FIXTHIS - should read col_limit from chart_config @@ -729,7 +729,7 @@ def make_testcase_table(test_name, chart_config, entries): html += row # one row per test case - tc_list = result_map.keys() + tc_list = list(result_map.keys()) tc_list.sort(key=functools.cmp_to_key(cmp_alpha_num)) for tc in tc_list: @@ -885,7 +885,7 @@ def make_testset_summary_table(test_name, chart_config, entries): html += row # one row per spec/build_number/test set - ssb_list = ssb_map.keys() + ssb_list = list(ssb_map.keys()) ssb_list.sort(ssb_cmp) # calculate rowspan for each spec and spec/build_number combo diff --git a/tests/Functional.LTP/ltp_process.py b/tests/Functional.LTP/ltp_process.py index 8a29830..8e2b637 100644 --- a/tests/Functional.LTP/ltp_process.py +++ b/tests/Functional.LTP/ltp_process.py @@ -269,7 +269,7 @@ def pts_set_style(ws): for cell in row: if cell.value: dims[cell.column] = max((dims.get(cell.column, 0), len(cell.value) + 2)) - for col, value in dims.items(): + for col, value in list(dims.items()): ws.column_dimensions[col].width = value if os.path.exists('pts.log'): -- 2.20.1