class Reader: # (hostname,id) => value in ms amavis = {} postfix = {} apattern = re.compile('^.* (.*) amavis\[.* \((.*)\) TIMING \[total (.*) ms\]') def readamavis(self,alog): f = open(alog) fsize = os.path.getsize(alog) s = 'start' counter = 0 while s : s = f.readline() if s: m = self.apattern.match(s) if m: groups = m.groups() key = ( groups[0], groups[1] ) value = groups[2] self.amavis[key] = value counter += 1 if counter > 1000: print 'done %f percent' % ( (float( f.tell()) / fsize) * 100 ) counter = 0 f.close() def readpostfix(self,plog): self.plog pass class Treebuilder: def buildtree(self,amavis, postfix): self.tree=[] #tree is a tuple unfinished when tupls is incomplete (third field) ( num num num ) (post a mavis post) ~