def parse_data(file_name): with open(file_name, "rb") as f: data = f.read().split("\n") for line in data: if len(line) == 0: continue elif line[0] != "#": temp_trace = Trace() temp_trace.parse_sc_analysis_dump_line(line) dict_add(ip_to_24subnet(temp_trace.dest_addr), temp_trace.path_length)
def parse_sc_analysis_dump_file(path_to_file): parsed_list = [] file_data = load_file(path_to_file) if not len(file_data): return file_data # filter header data file_data = filter(lambda x: len(x) > 0 and x[0] != '#', file_data) for data in file_data: temp_trace = Trace() temp_trace.parse_sc_analysis_dump_line(data) if temp_trace.dest_replied == "R": parsed_list.append((temp_trace.dest_addr, (temp_trace.timestamp, temp_trace.path_length, temp_trace.path_complete))) return parsed_list