def test_padding(self): """ The optional C{padding} parameter can be used to change the amount of padding used between columns. """ print_columns(self.outf, [["1234", "A description"]], padding=5) self.assertEquals(self.outf.getvalue(), "1234 A description\n")
def run(self, database_uri): setupLogging(self.outf) store = setupStore(database_uri, 'logs') rows = reportErrorSummary(store) print_columns(self.outf, rows, shrink_index=2) print >> self.outf print '%s occurrences of %s errors' % ( sum(int(item[0]) for item in rows), len(rows))
def run(self, database_uri): setupLogging(self.outf) store = setupStore(database_uri, 'logs') rows = reportErrorSummary(store) print_columns(self.outf, rows, shrink_index=2) print >> self.outf print '%s occurrences of %s errors' % (sum( int(item[0]) for item in rows), len(rows))
def test_max_width(self): """The optional C{max_width} parameter sets the maximum line length.""" description = ("A long description that will be truncated by the " "shrinking logic") print_columns(self.outf, [["1234", description]], shrink_index=1, max_width=68) self.assertEquals(self.outf.getvalue(), "1234 %s\n" % (description[:62],))
def run(self, database_uri, limit=None): if limit is None: limit = 15 setupLogging(self.outf) store = setupStore(database_uri, 'logs') rows = list(reportTraceLogSummary(store, limit)) print_columns(self.outf, rows) print >> self.outf print 'Top %s slowest requests' % limit
def test_max_width_ignored_without_shrink_index(self): """ The C{max_width} parameter is ignored if a C{shrink_index} isn't provided. """ description = ("A long description that will be truncated by the " "shrinking logic") print_columns(self.outf, [[description]], max_width=10) self.assertEquals(self.outf.getvalue(), "%s\n" % (description,))
def get_text(self): """Get topic content.""" stream = StringIO() command_names = self.controller.get_command_names() help_topic_names = self.controller.get_help_topic_names() result = [(name, self.controller.get_help_topic(name).get_summary()) for name in help_topic_names if name not in command_names] result.sort(key=lambda item: item[0]) print_columns(stream, result) return stream.getvalue()
def test_last_item_has_no_trailing_whitespace(self): """ The text for the last column output for each line shouldn't have any trailing whitespace. """ print_columns(self.outf, [["up"], ["down"]]) self.assertEquals(self.outf.getvalue(), """\ up down """)
def test_shrink_index(self): """ The optional C{shrink_index} parameter specifies the column to truncate, should the line being output exceed the C{max_width}. """ description = ("A long description that will be truncated by the " "shrinking logic") print_columns(self.outf, [["1234", description]], shrink_index=1) self.assertEquals(self.outf.getvalue(), "1234 %s\n" % (description[:71],))
def get_text(self): """Get topic content.""" stream = StringIO() result = [] for name in self.controller.get_command_names(): command = self.controller.get_command(name) help_topic = self.controller.get_help_topic(name) if not help_topic and command: help_topic = CommandHelpTopic(command) if self.controller is not None: help_topic.controller = self.controller summary = "" if help_topic: summary = help_topic.get_summary() if self.include_command(command): result.append((name, summary)) result.sort(key=lambda item: item[0]) print_columns(stream, result) return stream.getvalue()
def test_many_columns(self): """ A sequence of multi-element lists is printed as a list of columns. """ print_columns(self.outf, [["1234", "A description"]]) self.assertEquals(self.outf.getvalue(), "1234 A description\n")
def test_one_column(self): """A sequence of single-element lists is printed as a list of items.""" print_columns(self.outf, [["1234"], ["2345"]]) self.assertEquals(self.outf.getvalue(), "1234\n2345\n")
def test_no_rows(self): """No output is produced if the input rows list is empty.""" print_columns(self.outf, []) self.assertEquals(self.outf.getvalue(), "")