Original, the clean flag work with previous testcase to form a separate call request to generator. the patch will append ":clean" to previous testcase to mark that the previous testcase needs to clean after running. It make counting of testcase number easier. And rename the function and variable, add more comments --- mapper.py | 71 +++++++++++++++++++++++++++++------------------------------- 1 files changed, 34 insertions(+), 37 deletions(-) diff --git a/mapper.py b/mapper.py index c2c44da..5cf12e3 100644 --- a/mapper.py +++ b/mapper.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# libvirt-test-API is copyright 2010 Red Hat, Inc. +# libvirt-test-API is copyright 2010, 2012 Red Hat, Inc. # # libvirt-test-API is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -17,8 +17,6 @@ # the purpose is to get useful information about a testrun. # -import copy - class Mapper(object): def __init__(self, testcases_list): @@ -27,54 +25,53 @@ class Mapper(object): def module_casename_func_map(self): """ generate a new list of dictionary change key from module:casename to module:casename:func + if clean flag is set, key will be module:casename:func:clean """ - tripped_cases_list = [] - prev_testcasename = '' - prev_testcases_params = '' + new_case_list = [] for testcase in self.testcases_list: - tripped_case = {} - testcase_name = testcase.keys()[0] - if ":" in testcase_name: - casename = testcase_name.split(":")[1] + case = {} + mod_case = testcase.keys()[0] + if ":" in mod_case: + casename = mod_case.split(":")[1] func = casename - if testcase_name == 'sleep': - tripped_cases_list.append(testcase) + if mod_case == 'sleep': + new_case_list.append(testcase) continue - if testcase_name == 'clean': - func = casename + "_clean" - tripped_case[prev_testcasename + ":" + func] = prev_testcases_params - tripped_cases_list.append(tripped_case) - continue + if mod_case == 'clean': + if not new_case_list: + return None - testcases_params = testcase.values()[0] - tripped_case[testcase_name + ":" + func] = testcases_params - tripped_cases_list.append(tripped_case) + previous_case = new_case_list.pop() + key = previous_case.keys()[0] + ':clean' + case[key] = previous_case.values()[0] + new_case_list.append(case) + continue - prev_testcasename = testcase_name - prev_testcases_params = testcases_params + cases_params = testcase.values()[0] + case[mod_case + ":" + func] = cases_params + new_case_list.append(case) - return tripped_cases_list + return new_case_list - def module_casename_cleanfunc_map(self): - """generate a new data format - keys of dictionay are of module:casename:casename_clean + def module_casename_func_noflag(self): + """remove sleep and clean data + generate a new data format """ - tripped_cases_list = [] + new_case_list = [] for testcase in self.testcases_list: - tripped_case = {} - testcase_name = testcase.keys()[0] - if ":" in testcase_name: - casename = testcase_name.split(":")[1] - func = casename + "_clean" + case = {} + mod_case = testcase.keys()[0] - if testcase_name == 'sleep' or testcase_name == 'clean': + if mod_case == 'sleep' or mod_case == 'clean': continue - testcases_params = testcase.values()[0] - tripped_case[testcase_name + ":" + func] = testcases_params - tripped_cases_list.append(tripped_case) + func = mod_case.split(":")[1] + + cases_params = testcase.values()[0] + case[mod_case + ":" + func] = cases_params + new_case_list.append(case) - return tripped_cases_list + return new_case_list -- 1.7.7.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list