def parse_for_todo(self, content): """ :param content a list of [sha, file_name, blob] from our db """ if not content: return try: ext = self.get_extension(content[1])[1] except IndexError: print content return try: if ext is not None: comment = lookup_ext(ext)[0] except KeyError: self.db.delete_row({'sha': content[0], 'file_name': content[1]}) return for line in content[2].splitlines(): if 'TODO' in line and line.startswith(comment): todo_line = self._sanitize_todo_line(line, ext) print 'Found TODO: {}'.format(todo_line) data_dict = self.construct_data_dict(content[1], todo_line, content[3], content[4]) self.send_to_restful(data_dict)
def _sanitize_todo_line(line, file_ext): line = line.replace('\n', '') while ' ' in line or '\t' in line: line = line.replace(' ', '') for ext in lookup_ext(file_ext): line = line.replace(ext, '') return line