# dictionary login -> [list of roles] rolepacks = {} def read_role_body(header, raw, curline): login = raw[header['who']] raw_role = raw[header['role']].split(lib.tsep) roles = [] for str_role in raw_role: if str_role == '': break raw_role = str_role.split(lib.fsep) newpack = lib.infopack() newpack.data = raw_role[1] newpack.when = int(raw_role[0]) roles.append(newpack) rolepacks[login] = roles lib.read_file(sys.argv[2], lib.empty_header, read_role_body) # 2) link to level4_assigning def link_header(header, raw, curline): print curline[:-1] + lib.sep + sys.argv[5] + '_role' def link_body(header, raw, curline): login = raw[header[sys.argv[3]]] when = int(raw[header[sys.argv[4]]]) # no one should remain 'unknow' role = 'unknow' if rolepacks.has_key(login): index = lib.binary_search(rolepacks[login], lib.func_time, when) if index >= 0: role = rolepacks[login][index].data
global cntMaxExp login = raw[header['login']] if login == actor: # cntN cntN = GetValueByTimeFromStr(raw[header['contacter_num']], actionTime) # cntMaxExp cntMaxExp = GetValueByTimeFromStr(raw[header['max_contecter_exp']], actionTime) return 1 def ReadCommentRecord(header, raw, curline): global cmtN login = raw[header['login']] if login == actor: # cmtN cmtN = GetValueByTimeFromStr(raw[header['cmt_num']], actionTime) return 1 lib.read_file(sys.argv[1], lib.empty_header, ReadProductAssignmentRecord) lib.read_file(sys.argv[2], lib.empty_header, ReadLoginProductAssignmentRecord) lib.read_file(sys.argv[3], lib.empty_header, ReadLoginPeerRecord) lib.read_file(sys.argv[4], lib.empty_header, ReadCommentRecord) print str(nPrdCorAssi) + ',' + str(nPrdAssi) + ',' + str(nLogPrdCorAssi) + ',' + str(nLogPrdAssi) + ',' + str(cntMaxExp) + ',' + str(cntN) + ',' + str(cmtN)
# exp raw_exps = raw[header['max_contecter_exp']].split(lib.tsep) exp_packs = [] for raw_exp in raw_exps: if raw_exp == '': continue raw_pack = raw_exp.split(lib.fsep) exp = int(raw_pack[0]) time = int(raw_pack[1]) newpack = lib.infopack() newpack.data = exp newpack.when = time exp_packs.append(newpack) con_exp[login] = exp_packs lib.read_file(sys.argv[2], lib.empty_header, read_contact_info) # link to target file def link_header(header, raw, curline): print curline[:-1] + lib.sep + 'cnt_num' + lib.sep + 'cnt_max_exp' def link_body(header, raw, curline): global con_num, con_exp, con_dev login = raw[header['login']] when = int(raw[header['when']]) # num num = 0 if con_num.has_key(login): num_index = lib.binary_search(con_num[login], lib.func_time, when)
global alias global use_email who = raw[header['who']] when = int(raw[header['when']]) if use_email: name = who.split('@')[0] if not alias.has_key(name): alias[name] = {} alias[name][who] = 1 if not actors.has_key(who): actors[who] = actor() actors[who].nonself_since = when lib.read_file(sys.argv[2], lib.empty_header, read_reporter_body) # read maintainer namelist def read_maint_body(header, raw, curline): global actors global alias global use_email who = raw[header['who']] if use_email: name = who.split('@')[0] if not alias.has_key(name): alias[name] = {} alias[name][who] = 1 if not actors.has_key(who):
global bug_final_time if bug_id in bug_fixed: # no need to care about it return if llevel4_type == '0': final_time = int((raw[header['product']].split(lib.tsep)[-1]).split(lib.fsep)[1]) bug_final_time[bug_id] = final_time elif llevel4_type == '1': # get time for fields in field_set bug_final_time[bug_id] = {} for field in field_set: final_time = int((raw[header[field]].split(lib.tsep)[-1]).split(lib.fsep)[1]) bug_final_time[bug_id][field] = final_time # read llevel3 lib.read_file(sys.argv[3], lib.empty_header, read_llevel3_body) # bug_id -> the first time of verifying the final action bug_verifying_time = {} # read activity level2 def read_level2(header, raw, curline): global bug_resolving_time global bug_confirmed global bug_fixed global bug_final_time bug_id = raw[header['bug_id']] # we ignore some bugs, because they don't need this information if (not bug_resolving_time.has_key(bug_id)) or (bug_id in bug_confirmed) or (bug_id in bug_fixed) or (not bug_final_time.has_key(bug_id)):
if bug_id != cur_bug_id: cur_bug_id = bug_id cur_set = set() login = raw[header['who']] when = int(raw[header['when']]) month_aligned_when = lib.month_align(when) cur_set.add(login) if not logins.has_key(login): logins[login] = {} if not logins[login].has_key(month_aligned_when): logins[login][month_aligned_when] = contacters() logins[login][month_aligned_when].logins = cur_set.union(logins[login][month_aligned_when].logins) lib.read_file(sys.argv[1], lib.empty_header, read_lcmt_level2_body) # step 2) read login general experience # dictionary login -> [list of <exp,when> tuples] login_exp = {} def read_body(header, raw, curline): who = raw[header['who']] exps = raw[header['exp']].split(lib.tsep) explist = [] for str_exp in exps: if str_exp == '': break raw_exp = str_exp.split(lib.fsep) newpack = lib.infopack() newpack.data = int(raw_exp[0]) newpack.when = int(raw_exp[1])
#!/usr/bin/python # Author: Xie Jialiang # Date: 2013-05-23 # Function: link correct or not to level4_info # Parameters: 1) level4_info # Output stream: linked level4_info import sys import leon_lib as lib # read target file def read_llevel4_info_header(header, raw, curline): print curline[:-1] + lib.sep + 'correct' def read_llevel4_info_body(header, raw, curline): new = raw[header['new']].lower() final = raw[header['final']].lower() print curline[:-1] + lib.sep + str(new == final) lib.read_file(sys.argv[1], read_llevel4_info_header, read_llevel4_info_body)
'target_milestone':'Target Milestone', 'version':'Version', 'blocked':'Blocks', 'dependson':'Depends on', 'hardware':'Hardware', 'flag':'Flags', 'target_milestone':'Target Milestone'} def read_head(header, raw, curline): print curline[:-1] def read_body(header, raw, curline): bug_id = raw[header['bug_id']] who = raw[header['who']] when = raw[header['when']] what = raw[header['what']] old = raw[header['old']] new = raw[header['new']] if uniform_dic.has_key(what): what = uniform_dic[what] print bug_id + ';;' + who + ';' + when + ';' + what + ';' + old + ';' + new lib.read_file(sys.argv[1], read_head, read_body)
def read_login_comment_number(header, raw, curline): global login_cmt login = raw[header['login']] raw_cmt = raw[header['cmt_num']].split(lib.tsep) cmt_num = [] for str_num in raw_cmt: raw_num = str_num.split(lib.fsep) newpack = lib.infopack() newpack.data = int(raw_num[0]) newpack.when = int(raw_num[1]) cmt_num.append(newpack) login_cmt[login] = cmt_num lib.read_file(sys.argv[2], lib.empty_header, read_login_comment_number) # link to target file def link_header(header, raw, curline): print curline[:-1] + lib.sep + 'cmt_num' def link_body(header, raw, curline): global login_cmt login = raw[header['login']] when = int(raw[header['when']]) num = 0 if login_cmt.has_key(login):
resolved_time = lib.resolved_time_checker() resolved_time.read(sys.argv[4]) # read final product bug_final_product = {} def read_final_product_body(header, raw, curline): global bug_final_product bug_id = raw[header['bug_id']] final_product = (raw[header['product']].split(lib.tsep)[-1]).split( lib.fsep)[0] bug_final_product[bug_id] = final_product lib.read_file(sys.argv[4], lib.empty_header, read_final_product_body) # add to dict def add_to_dict(dict, a, b, c): if not dict.has_key(a): dict[a] = {} if not dict[a].has_key(b): dict[a][b] = {} if not dict[a][b].has_key(c): dict[a][b][c] = 0 dict[a][b][c] += 1 logPrdAssi = {} logPrdNotAssi = {}
# read product convertion convertion = lib.product_convertion() convertion.read_product_convertion(sys.argv[5]) # read leon_level3 resolved_time = lib.resolved_time_checker() resolved_time.read(sys.argv[4]) # read final product bug_final_product = {} def read_final_product_body(header, raw, curline): global bug_final_product bug_id = raw[header['bug_id']] final_product = (raw[header['product']].split(lib.tsep)[-1]).split(lib.fsep)[0] bug_final_product[bug_id] = final_product lib.read_file(sys.argv[4], lib.empty_header, read_final_product_body) # add to dict def add_to_dict(dict, a, b, c): if not dict.has_key(a): dict[a] = {} if not dict[a].has_key(b): dict[a][b] = {} if not dict[a][b].has_key(c): dict[a][b][c] = 0 dict[a][b][c] += 1 logPrdAssi = {} logPrdNotAssi = {} def read_triage_body(header, raw, curline):
login_cmt = {} def read_login_comment_number(header, raw, curline): global login_cmt login = raw[header['login']] raw_cmt = raw[header['cmt_num']].split(lib.tsep) cmt_num = [] for str_num in raw_cmt: raw_num = str_num.split(lib.fsep) newpack = lib.infopack() newpack.data = int(raw_num[0]) newpack.when = int(raw_num[1]) cmt_num.append(newpack) login_cmt[login] = cmt_num lib.read_file(sys.argv[2], lib.empty_header, read_login_comment_number) # link to target file def link_header(header, raw, curline): print curline[:-1] + lib.sep + 'cmt_num' def link_body(header, raw, curline): global login_cmt login = raw[header['login']] when = int(raw[header['when']]) num = 0 if login_cmt.has_key(login): index = lib.binary_search(login_cmt[login], lib.func_time, when) if index >= 0:
login = raw[header['login']] if login == actor: # cmtN cmtN = GetValueByTimeFromStr(raw[header['cmt_num']], actionTime) return 1 def ReadRoleRecord(header, raw, curline): global role login = raw[header['who']] if login == actor: role = GetValueByTimeFromStr(raw[header['role']], actionTime) lib.read_file(sys.argv[1], lib.empty_header, ReadProductAssignmentRecord) lib.read_file(sys.argv[2], lib.empty_header, ReadLoginProductAssignmentRecord) lib.read_file(sys.argv[3], lib.empty_header, ReadLoginPeerRecord) lib.read_file(sys.argv[4], lib.empty_header, ReadCommentRecord) lib.read_file(sys.argv[5], lib.empty_header, ReadRoleRecord) print str(nPrdCorAssi) + ',' + str(nPrdAssi) + ',' + str( nLogPrdCorAssi) + ',' + str(nLogPrdAssi) + ',' + str( cntMaxExp) + ',' + str(cntN) + ',' + str(cmtN) + ',' + '\"' + str( role) + '\"'
raw_exps = raw[header['max_contecter_exp']].split(lib.tsep) exp_packs = [] for raw_exp in raw_exps: if raw_exp == '': continue raw_pack = raw_exp.split(lib.fsep) exp = int(raw_pack[0]) time = int(raw_pack[1]) newpack = lib.infopack() newpack.data = exp newpack.when = time exp_packs.append(newpack) con_exp[login] = exp_packs lib.read_file(sys.argv[2], lib.empty_header, read_contact_info) # link to target file def link_header(header, raw, curline): print curline[:-1] + lib.sep + 'cnt_num' + lib.sep + 'cnt_max_exp' def link_body(header, raw, curline): global con_num, con_exp, con_dev login = raw[header['login']] when = int(raw[header['when']]) # num num = 0
return if llevel4_type == '0': final_time = int( (raw[header['product']].split(lib.tsep)[-1]).split(lib.fsep)[1]) bug_final_time[bug_id] = final_time elif llevel4_type == '1': # get time for fields in field_set bug_final_time[bug_id] = {} for field in field_set: final_time = int( (raw[header[field]].split(lib.tsep)[-1]).split(lib.fsep)[1]) bug_final_time[bug_id][field] = final_time # read llevel3 lib.read_file(sys.argv[3], lib.empty_header, read_llevel3_body) # bug_id -> the first time of verifying the final action bug_verifying_time = {} # read activity level2 def read_level2(header, raw, curline): global bug_resolving_time global bug_confirmed global bug_fixed global bug_final_time bug_id = raw[header['bug_id']] # we ignore some bugs, because they don't need this information
def read_role_body(header, raw, curline): login = raw[header['who']] raw_role = raw[header['role']].split(lib.tsep) roles = [] for str_role in raw_role: if str_role == '': break raw_role = str_role.split(lib.fsep) newpack = lib.infopack() newpack.data = raw_role[0] newpack.when = int(raw_role[1]) roles.append(newpack) rolepacks[login] = roles lib.read_file(sys.argv[2], lib.empty_header, read_role_body) # 2) link to level4_assigning def link_header(header, raw, curline): print curline[:-1] + lib.sep + sys.argv[5] + '_role' def link_body(header, raw, curline): login = raw[header[sys.argv[3]]] when = int(raw[header[sys.argv[4]]]) # no one should remain 'unknow' role = 'unknow' if rolepacks.has_key(login): index = lib.binary_search(rolepacks[login], lib.func_time, when)
info_packs[bug_id].os = value elif key == 'priority': info_packs[bug_id].priority = value elif key == 'product': info_packs[bug_id].product = value elif key == 'reporter': info_packs[bug_id].reporter = value elif key == 'resolution': info_packs[bug_id].resolution = value elif key == 'target_milestone': info_packs[bug_id].target_milestone = value elif key == 'version': info_packs[bug_id].version = value # read linfo_level2 lib.read_file(sys.argv[1], lib.empty_header, read_linfo_level2_body) # 2) read activity level2 class act_pack: def act_pack(self): self.time = 0 self.old = '' self.new = '' self.who = '' class issue: def __init__(self): # basic info self.bug_id = '' self.reporter = ''
if not n_tri[field][login].has_key(product): n_tri[field][login][product] = {} if not n_tri[field][login][product].has_key(valid_t): n_tri[field][login][product][valid_t] = 0 n_tri[field][login][product][valid_t] += 1 # n_cor_tri if is_correct: if not n_cor_tri[field].has_key(login): n_cor_tri[field][login] = {} if not n_cor_tri[field][login].has_key(product): n_cor_tri[field][login][product] = {} if not n_cor_tri[field][login][product].has_key(valid_t): n_cor_tri[field][login][product][valid_t] = 0 n_cor_tri[field][login][product][valid_t] += 1 lib.read_file(sys.argv[1], lib.empty_header, read_body) # output print 'login' + lib.sep + 'product' + lib.sep + 'field' + lib.sep + 'n_tri' + lib.sep + 'n_cor_tri' for field in n_tri: for login in n_tri[field]: for product in n_tri[field][login]: # n_tri str_tri = '' timelist = sorted(n_tri[field][login][product].keys()) count = 0 for time in timelist: count += n_tri[field][login][product][time] str_tri += str(count) + lib.fsep + str(time) + lib.tsep if str_tri.__len__() > 0: str_tri = str_tri[:-lib.tsep.__len__()]
bugID = raw[header['bug_id']] if bugID != targetID: # if seen target and it is not target now, skip the rest if seenTarget: return -1 else: return 0 seenTarget = True field = raw[header['field']] if curDict.has_key(field): curDict[field] = raw[header['what']] # read linfo_level2 lib.read_file(sys.argv[1], lib.empty_header, read_linfo_level2_body) if not seenTarget: print 'False' + sep + 'who' + sep + 'when' + sep + 'noSuchBug' + 'False' + sep + 'who' + sep + 'when' + sep + 'noSuchBug' sys.exit(1) if curDict['status'] == 'RESOLVED' or curDict[ 'status'] == 'VERIFIED' or curDict['status'] == 'CLOSED': # print 'False,who,when,' + curDict['status'] # sys.exit(1) pass # prepare read activity to find out who@when set the current value actList = [] seenTarget = False
global use_email who = raw[header['who']] when = int(raw[header['when']]) if use_email: name = who.split('@')[0] if not alias.has_key(name): alias[name] = {} alias[name][who] = 1 if not actors.has_key(who): actors[who] = actor() actors[who].nonself_since = when lib.read_file(sys.argv[2], lib.empty_header, read_reporter_body) # read maintainer namelist def read_maint_body(header, raw, curline): global actors global alias global use_email who = raw[header['who']] if use_email: name = who.split('@')[0] if not alias.has_key(name): alias[name] = {} alias[name][who] = 1
# get issue reporter # dictionary bug_id -> reporter issue_reporter = {} def read_body(header, raw, curline): global issue_reporter bug_id = raw[header['bug_id']] field = raw[header['field']] what = raw[header['what']] if field == 'reporter': issue_reporter[bug_id] = what lib.read_file(sys.argv[1], lib.empty_header, read_body) # only reporter # dictionary login -> the first time she touched others issues, -1 means never touch_others = {} def read_act_body(header, raw, curline): global touch_others global issue_reporter issue = raw[header['bug_id']] actor = raw[header['who']] if not touch_others.has_key(actor): # the first time we meet the gay, assume it only touch its own issues touch_others[actor] = -1
'bug_severity': 'Severity', 'bug_status': 'Status', 'target_milestone': 'Target Milestone', 'version': 'Version', 'blocked': 'Blocks', 'dependson': 'Depends on', 'hardware': 'Hardware', 'flag': 'Flags', 'target_milestone': 'Target Milestone' } def read_head(header, raw, curline): print curline[:-1] def read_body(header, raw, curline): bug_id = raw[header['bug_id']] who = raw[header['who']] when = raw[header['when']] what = raw[header['what']] old = raw[header['old']] new = raw[header['new']] if uniform_dic.has_key(what): what = uniform_dic[what] print bug_id + ';;' + who + ';' + when + ';' + what + ';' + old + ';' + new lib.read_file(sys.argv[1], read_head, read_body)