for name in os.listdir(path): if "behavior" not in name: continue fullname = os.path.join(path, name) f = open(fullname, "r") for line in f: time, operation = processLine(line) duration = time - prev_time prev_time = time try: ops = fromText(operation) except KeyError: ops = None if ops: tup = s.toTuple() count[tup] = count.get(tup, 0) + 1 ac = actionCount.get(tup, {}) ac[ops] = ac.get(ops,0) + 1 actionCount[tup] = ac if tup not in action: action[tup] = [(ops, duration)] else: action[tup].append((ops, duration)) s.transition(ops) s.init() prev_time = 0 print s.range()