def parse_innotop_mode_m(self):
with open(self.infile, '<STR_LIT:r>') as infh:<EOL><INDENT>max_row_quot = <NUM_LIT:0><EOL>valrow = -<NUM_LIT:1><EOL>thisrowcolumns = {}<EOL>data = {}<EOL>last_ts = None<EOL>while True:<EOL><INDENT>line1 = infh.readline()<EOL>words = line1.split()<EOL>infh.readline()<EOL>is_header = True<EOL>for word in words:<EOL><INDENT>if naarad.utils.is_number(word):<EOL><INDENT>last_ts = words[<NUM_LIT:0>].strip().replace('<STR_LIT:T>', '<STR_LIT:U+0020>')<EOL>is_header = False<EOL>break  <EOL><DEDENT><DEDENT>if len(words) > <NUM_LIT:2> and is_header:<EOL><INDENT>thisrowcolumns[max_row_quot] = words[<NUM_LIT:2>:]<EOL>for column in thisrowcolumns[max_row_quot]:<EOL><INDENT>data[column] = []<EOL><DEDENT>max_row_quot += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if not last_ts:<EOL><INDENT>logger.warn("<STR_LIT>", self.infile)<EOL>return True<EOL><DEDENT>infh.seek(<NUM_LIT:0>)<EOL>is_bad_line = False<EOL>outfilehandlers = {}<EOL>for line in infh:<EOL><INDENT>l = line.strip().split('<STR_LIT:U+0020>', <NUM_LIT:1>)<EOL>if len(l) <= <NUM_LIT:1>:<EOL><INDENT>continue<EOL><DEDENT>ts = l[<NUM_LIT:0>].strip().replace('<STR_LIT:T>', '<STR_LIT:U+0020>')<EOL>if ts != last_ts:<EOL><INDENT>last_ts = ts<EOL>valrow = -<NUM_LIT:1><EOL><DEDENT>nameval = l[<NUM_LIT:1>].strip().split('<STR_LIT:\t>', <NUM_LIT:1>)<EOL>try:<EOL><INDENT>words = nameval[<NUM_LIT:1>].split('<STR_LIT:\t>')<EOL><DEDENT>except IndexError:<EOL><INDENT>logger.warn("<STR_LIT>", line)<EOL>continue<EOL><DEDENT>valrow += <NUM_LIT:1><EOL>command = nameval[<NUM_LIT:0>]<EOL>if command not in outfilehandlers:<EOL><INDENT>outfilehandlers[command] = {}<EOL><DEDENT>quot = valrow % max_row_quot<EOL>columns = thisrowcolumns[quot]<EOL>for i in range(len(words)):<EOL><INDENT>if len(words) > len(columns):<EOL><INDENT>logger.warn("<STR_LIT>", line)<EOL>logger.warn("<STR_LIT>", len(words), len(columns))<EOL>break<EOL><DEDENT>if words[i] in columns:<EOL><INDENT>logger.warn("<STR_LIT>", line)<EOL>valrow -= <NUM_LIT:1><EOL>break<EOL><DEDENT>if self.options and columns[i] not in self.options:<EOL><INDENT>continue<EOL><DEDENT>if columns[i] not in outfilehandlers[command]:<EOL><INDENT>outfilehandlers[command][columns[i]] = open(self.get_csv_C(command, columns[i]), '<STR_LIT:w>')<EOL>self.csv_files.append(self.get_csv_C(command, columns[i]))<EOL><DEDENT>ts = naarad.utils.reconcile_timezones(ts, self.timezone, self.graph_timezone)<EOL>outfilehandlers[command][columns[i]].write(ts + '<STR_LIT:U+002C>')<EOL>outfilehandlers[command][columns[i]].write(words[i])<EOL>outfilehandlers[command][columns[i]].write('<STR_LIT:\n>')<EOL><DEDENT><DEDENT>for command in outfilehandlers:<EOL><INDENT>for column in outfilehandlers[command]:<EOL><INDENT>outfilehandlers[command][column].close()<EOL><DEDENT><DEDENT><DEDENT>return True<EOL>
Special parsing method for Innotop "Replication Status" results (innotop --mode M)