def __str__(self): #has_colours = stream_has_colours(stream) has_colours = True lines = [] app = lines.append app("Events found in %s\n" % self.filename) for i, event in enumerate(self): if has_colours: app("[%d] %s" % (i+1, colored(event.header, color=event.color))) app(indent(event.message, 4)) else: app("[%d] %s" % (i+1, str(event))) app("num_errors: %s, num_warnings: %s, num_comments: %s, completed: %s\n" % ( self.num_errors, self.num_warnings, self.num_comments, self.run_completed)) return "\n".join(lines)