def diff_event_edge(conf1, conf2): d_set1 = defaultdict(set) d_set2 = defaultdict(set) d_diff = {} dirname = conf1.get("dag", "event_dir") for fp in common.rep_dir(dirname): fn = fp.split("/")[-1] edict1, evmap1 = log2event.load_edict(fp) for evdef in [evmap1.info(k) for k in edict1.keys()]: d_set1[fn].add(evdef) dirname = conf2.get("dag", "event_dir") for fp in common.rep_dir(dirname): fn = fp.split("/")[-1] edict2, evmap2 = log2event.load_edict(fp) for evdef in [evmap2.info(k) for k in edict2.keys()]: d_set2[fn].add(evdef) for k in d_set1.keys(): if not d_set2.has_key(k): raise KeyError("{0} not found in event set 2".format(k)) s1 = d_set1[k] s2 = d_set2[k] d_diff[k] = (s1 - s2) return d_diff
def get_dict_eventset(conf): d_set = defaultdict(set) dirname = conf.get("dag", "event_dir") for fp in common.rep_dir(dirname): fn = fp.split("/")[-1] temp_edict, temp_evmap = log2event.load_edict(fp) for k in temp_edict.keys(): evdef = temp_evmap.info(k) d_set[fn].add(evdef) return d_set
def get_dict_event_replaced(conf): d = {} type_rp = log2event.EventDefinitionMap.type_periodic_remainder dirname = conf.get("dag", "event_dir") for fp in common.rep_dir(dirname): fn = fp.split("/")[-1] edict, evmap = log2event.load_edict(fp) l_evdef = [] for eid in edict.keys(): evdef = evmap.info(eid) if evdef.type == type_rp: l_evdef.append(evdef) else: pass if len(l_evdef) > 0: d[fn] = l_evdef return d
def event_label(conf): import log_db ld = log_db.LogData(conf) import lt_label ll = lt_label.init_ltlabel(conf) d_group = defaultdict(int) dirname = conf.get("dag", "event_dir") for fp in common.rep_dir(dirname): fn = fp.split("/")[-1] edict, evmap = log2event.load_edict(fp) for evdef in [evmap.info(k) for k in edict.keys()]: gid = evdef.gid l_lt = ld.ltg_members(gid) group = ll.get_ltg_group(gid, l_lt) d_group[group] += 1 return d_group
def event_replaced(conf): type_rp = log2event.EventDefinitionMap.type_periodic_remainder dirname = conf.get("dag", "event_dir") for fp in common.rep_dir(dirname): fn = fp.split("/")[-1] area, gid = fn.split("_") edict, evmap = log2event.load_edict(fp) l_evdef = [] for eid in edict.keys(): evdef = evmap.info(eid) if evdef.type == type_rp: l_evdef.append(evdef) else: pass if len(l_evdef) > 0: print("# {0}".format(fn)) for evdef in l_evdef: print(evdef)
def count_event_label(conf): import log2event ld = log_db.LogData(conf) ll = init_ltlabel(conf) d_label = defaultdict(int) d_group = defaultdict(int) dirname = conf.get("dag", "event_dir") for fp in common.rep_dir(dirname): fn = fp.split("/")[-1] edict, evmap = log2event.load_edict(fp) for eid, l_dt in edict.items(): gid = evmap.info(eid).gid l_lt = ld.ltg_members(gid) label = ll.get_ltg_label(gid, l_lt) group = ll.get_group(label) d_label[label] += len(l_dt) d_group[group] += len(l_dt) print("all lines : {0}".format(sum(d_group.values()))) print() for group, l_label in ll.d_group.items(): if group in d_group: cnt_group = d_group.pop(group) else: cnt_group = 0 print("group {0}: {1} lines".format(group, cnt_group)) for label in l_label: if label in d_label: cnt_label = d_label.pop(label) else: cnt_label = 0 print(" label {0}: {1} lines".format(label, cnt_label)) print()