def init_projections(self): # check for all the projections used print "Identify projections..." self.projection = 'root' self.projections = set([ 'root' ]) for e in self.events: if not logs.state_event_filter(e): continue data = e.get('data',None) if not data: continue if 'state' not in data: continue protocolName = data['stateType'] module = custom.load(self,protocolName) if not module: continue for name, namefunc in module.projections(data): self.projections.add(name) self.projections.remove('root') self.projections = sorted(list(self.projections)) self.projections = ['root'] + self.projections def compute_leaves(projections): temp = projections[:] temp.remove('root') temp.sort(key=lambda x: -len(x)) lv = [] def is_prefix(s): for s2 in lv: if s2.startswith(s): return True return False for t in temp: if not is_prefix(t): lv += [t] return lv self.leaf_projections = compute_leaves(self.projections)
def pf(e): return logs.state_event_filter(e) and data_filter(e['data'])