#coding: utf-8
import json
def test():
aa = [{u'iTestID': 92478, u'all_case_count': 45103, u'refresh_time': u'2016-11-29 17:03:01', u'version_num': u'BaseOn_W16.38_PassList_0916', u'test_month': u'09', u'bug_count': 347, u'fail_count': 420,u'test_week': u'37', u'summary_type': u'TRUNK', u'confirm_rate': u'100.0000%', u'pass_count': 44683, u'test_year': u'2016', u'id': 716}, {u'iTestID': 92477, u'all_case_count': 953, u'refresh_time': u'2016-11-29 17:03:01', u'version_num': u'FM_BASE_W16.38', u'test_month': u'09', u'bug_count': 188, u'fail_count': 301, u'test_week': u'37', u'summary_type': u'TRUNK', u'confirm_rate': u'100.0000%', u'pass_count': 652, u'test_year': u'2016', u'id': 717}]
result = []
for i in range(0,len(aa)):
sum_all_case_count,sum_pass_count,sum_bug_count, sum_fail_count,flag,sum_oldfail_count,sum_newfail_count = 0,0,0,0,0,0,0
for r in result:
bb = aa[i]['version_num'].split('_W')
if bb[1][:5] in r['version_num']:
flag = 1
if flag == 0:
for j in range(0,len(aa)):
print aa[j]['version_num'].split('_W')
if (aa[i]['version_num'].split('_W'))[1][:5] in (aa[j]['version_num'].split('_W')[1]):
#aa[i]['version_num'] = (aa[i]['version_num'].split('_W'))[1][0:5]
sum_all_case_count = sum_all_case_count+aa[j]['all_case_count']
sum_pass_count = sum_pass_count+aa[j]['pass_count']
sum_bug_count = sum_bug_count+aa[j]['bug_count']
sum_fail_count = sum_fail_count+aa[j]['fail_count']
if 'FM_BASE' in aa[j]['version_num']:
sum_oldfail_count = sum_oldfail_count +aa[j]['fail_count']
if 'PassList' in aa[j]['version_num']:
sum_newfail_count = sum_newfail_count +aa[j]['fail_count']
one_record = dict(version_num=aa[i]['version_num'],
sum_all_case_count=sum_all_case_count,
sum_pass_count=sum_pass_count,
sum_bug_count=sum_bug_count,
sum_fail_count=sum_fail_count,
sum_oldfail_count=sum_oldfail_count,
sum_newfail_count =sum_newfail_count
)
result.append(one_record)
print result
if __name__ == '__main__':
test()