def link_body(header, raw, curline): new = raw[header[field_name]].lower() new = convertion.rename(new) when = int(raw[header['when']]) field = raw[header['field']] # n_tri n_tri_i = 0 if n_tri.has_key(field) and n_tri[field].has_key(new): index = lib.binary_search(n_tri[field][new], lib.func_time, when) if index >= 0: n_tri_i = n_tri[field][new][index].data # n_cor_tri n_cor_tri_i = 0 if n_cor_tri.has_key(field) and n_cor_tri[field].has_key(new): index = lib.binary_search(n_cor_tri[field][new], lib.func_time, when) if index >= 0: n_cor_tri_i = n_cor_tri[field][new][index].data # for overall products n_all_tri_i = 0 if n_tri.has_key(field): for prd in n_tri[field]: index = lib.binary_search(n_tri[field][prd], lib.func_time, when) if index >= 0: n_all_tri_i += n_tri[field][prd][index].data n_all_cor_tri_i = 0 if n_cor_tri.has_key(field): for prd in n_cor_tri[field]: index = lib.binary_search(n_cor_tri[field][prd], lib.func_time, when) if index >= 0: n_all_cor_tri_i += n_cor_tri[field][prd][index].data # output print curline[:-1] + lib.sep + str(n_tri_i) + lib.sep + str(n_cor_tri_i) + lib.sep + str(n_all_tri_i) + lib.sep + str(n_all_cor_tri_i)
def link_body(header, raw, curline): login = raw[header['login']] when = int(raw[header['when']]) # n_assi n_assi_i = 0 if n_assi.has_key(login): index = lib.binary_search(n_assi[login], lib.func_time, when) if index >= 0: n_assi_i = n_assi[login][index].data # n_cor_assi n_cor_assi_i = 0 if n_cor_assi.has_key(login): index = lib.binary_search(n_cor_assi[login], lib.func_time, when) if index >= 0: n_cor_assi_i = n_cor_assi[login][index].data # output print curline[:-1] + lib.sep + str(n_assi_i) + lib.sep + str(n_cor_assi_i)
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 print curline[:-1] + lib.sep + str(role)
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) if num_index >= 0: num = con_num[login][num_index].data # exp exp = 0 if con_exp.has_key(login): exp_index = lib.binary_search(con_exp[login], lib.func_time, when) if exp_index >= 0: exp = con_exp[login][exp_index].data print curline[:-1] + lib.sep + str(num) + lib.sep + str(exp)
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: num = login_cmt[login][index].data print curline[:-1] + lib.sep + str(num)
def link_body(header, raw, curline): login = raw[header['login']] new = raw[header[field_name]].lower() new = convertion.rename(new) when = int(raw[header['when']]) field = raw[header['field']] # n_tri n_tri_i = 0 if n_tri.has_key(field) and n_tri[field].has_key(login) and n_tri[field][login].has_key(new): index = lib.binary_search(n_tri[field][login][new], lib.func_time, when) if index >= 0: n_tri_i = n_tri[field][login][new][index].data # n_cor_tri n_cor_tri_i = 0 if n_cor_tri.has_key(field) and n_cor_tri[field].has_key(login) and n_cor_tri[field][login].has_key(new): index = lib.binary_search(n_cor_tri[field][login][new], lib.func_time, when) if index >= 0: n_cor_tri_i = n_cor_tri[field][login][new][index].data # output print curline[:-1] + lib.sep + str(n_tri_i) + lib.sep + str(n_cor_tri_i)
def link_body(header, raw, curline): login = raw[header['login']] new = raw[header['new']].lower() new = convertion.rename(new) when = int(raw[header['when']]) # expPrdAssi expPrdAssi = 0 if logPrdAssi.has_key(login) and logPrdAssi[login].has_key(new): index = lib.binary_search(logPrdAssi[login][new], lib.func_time, when) if index >= 0: expPrdAssi = logPrdAssi[login][new][index].data # expPrdNotAssi expPrdNotAssi = 0 if logPrdNotAssi.has_key(login) and logPrdNotAssi[login].has_key(new): index = lib.binary_search(logPrdNotAssi[login][new], lib.func_time, when) if index >= 0: expPrdNotAssi = logPrdNotAssi[login][new][index].data # expNotPrdAssi expNotPrdAssi = 0 if logPrdAssi.has_key(login): for product in logPrdAssi[login]: if product == new: continue index = lib.binary_search(logPrdAssi[login][product], lib.func_time, when) if index >= 0: expNotPrdAssi += logPrdAssi[login][product][index].data # expNotPrdNotAssi expNotPrdNotAssi = 0 if logPrdNotAssi.has_key(login): for product in logPrdNotAssi[login]: if product == new: continue index = lib.binary_search(logPrdNotAssi[login][product], lib.func_time, when) if index >= 0: expNotPrdNotAssi += logPrdNotAssi[login][product][index].data # output print curline[:-1] + lib.sep + str(expPrdAssi) + lib.sep + str(expPrdNotAssi) + lib.sep + str(expNotPrdAssi) + lib.sep + str(expNotPrdNotAssi)
def link_body(header, raw, curline): new = raw[header[field_name]].lower() new = convertion.rename(new) when = int(raw[header['when']]) field = raw[header['field']] # n_tri n_tri_i = 0 if n_tri.has_key(field) and n_tri[field].has_key(new): index = lib.binary_search(n_tri[field][new], lib.func_time, when) if index >= 0: n_tri_i = n_tri[field][new][index].data # n_cor_tri n_cor_tri_i = 0 if n_cor_tri.has_key(field) and n_cor_tri[field].has_key(new): index = lib.binary_search(n_cor_tri[field][new], lib.func_time, when) if index >= 0: n_cor_tri_i = n_cor_tri[field][new][index].data # for overall products n_all_tri_i = 0 if n_tri.has_key(field): for prd in n_tri[field]: index = lib.binary_search(n_tri[field][prd], lib.func_time, when) if index >= 0: n_all_tri_i += n_tri[field][prd][index].data n_all_cor_tri_i = 0 if n_cor_tri.has_key(field): for prd in n_cor_tri[field]: index = lib.binary_search(n_cor_tri[field][prd], lib.func_time, when) if index >= 0: n_all_cor_tri_i += n_cor_tri[field][prd][index].data # output print curline[:-1] + lib.sep + str(n_tri_i) + lib.sep + str( n_cor_tri_i) + lib.sep + str(n_all_tri_i) + lib.sep + str( n_all_cor_tri_i)
def link_body(header, raw, curline): login = raw[header['login']] new = raw[header[field_name]].lower() new = convertion.rename(new) when = int(raw[header['when']]) field = raw[header['field']] # n_tri n_tri_i = 0 if n_tri.has_key(field) and n_tri[field].has_key( login) and n_tri[field][login].has_key(new): index = lib.binary_search(n_tri[field][login][new], lib.func_time, when) if index >= 0: n_tri_i = n_tri[field][login][new][index].data # n_cor_tri n_cor_tri_i = 0 if n_cor_tri.has_key(field) and n_cor_tri[field].has_key( login) and n_cor_tri[field][login].has_key(new): index = lib.binary_search(n_cor_tri[field][login][new], lib.func_time, when) if index >= 0: n_cor_tri_i = n_cor_tri[field][login][new][index].data # output print curline[:-1] + lib.sep + str(n_tri_i) + lib.sep + str(n_cor_tri_i)
dates = sorted(logins[login].keys()) max_exp = 0 sign = False for date in dates: # it met new peers cur_set = cur_set.union(logins[login][date].logins) cur_max_exp = 0 # for each peer, find max experience for contactor in logins[login][date].logins: if login == contactor: # do not calculate itself continue if login_exp.has_key(contactor): index = lib.binary_search(login_exp[contactor], lib.func_time, date) if index >= 0: cur_exp = login_exp[contactor][index].data if cur_exp > cur_max_exp: cur_max_exp = cur_exp # check whether the max experince has been updated if cur_max_exp > max_exp: max_exp = cur_max_exp out_exp += str(max_exp) + lib.fsep + str(date) + lib.tsep if login in cur_set: # remove it self cur_set.remove(login) # check whether contact new people if cur_set.__len__() != cur_size: cur_size = cur_set.__len__()
def GetValueByTimeFromStr(string, time): seq = string.split(lib.tsep) index = lib.binary_search(seq, GetTimeFromStr, time) if index < 0: return 0 return GetValueFromStr(seq[index])
def GetValueByTimeFromStr(string, time): seq = string.split(lib.tsep) index = lib.binary_search(seq, GetTimeFromStr, time) if index < 0: return 0; return GetValueFromStr(seq[index])