def test_join(self): # check our pydoc examples self.assertEqual('This is a looooong', join(['This', 'is', 'a', 'looooong', 'message'], size = 18)) self.assertEqual('This is a', join(['This', 'is', 'a', 'looooong', 'message'], size = 17)) self.assertEqual('', join(['This', 'is', 'a', 'looooong', 'message'], size = 2)) # include a joining character self.assertEqual('Download: 5 MB, Upload: 3 MB', join(['Download: 5 MB', 'Upload: 3 MB', 'Other: 2 MB'], ', ', 30))
def _header(self, width, is_primary): if is_primary: header = CONFIG['attr.graph.header.primary'].get(self.stat_type(), '') header_stats = self._primary_header_stats else: header = CONFIG['attr.graph.header.secondary'].get(self.stat_type(), '') header_stats = self._secondary_header_stats header_stats = join(header_stats, '', width - len(header) - 4).rstrip() return '%s (%s):' % (header, header_stats) if header_stats else '%s:' % header
def _header(self, width, is_primary): if is_primary: header = CONFIG['attr.graph.header.primary'].get(self.stat_type(), '') header_stats = self._primary_header_stats else: header = CONFIG['attr.graph.header.secondary'].get(self.stat_type(), '') header_stats = self._secondary_header_stats header_stats = join(header_stats, '', width - len(header) - 4).rstrip() return '%s (%s):' % (header, header_stats) if header_stats else '%s:' % header
def title(self, width): """ Provides a graph title that fits in the given width. :param int width: maximum length of the title :returns: **str** with our title """ title = CONFIG['attr.graph.title'].get(self.stat_type(), '') title_stats = join(self._title_stats, ', ', width - len(title) - 4) return '%s (%s):' % (title, title_stats) if title_stats else title + ':'
def title(self, width): """ Provides a graph title that fits in the given width. :param int width: maximum length of the title :returns: **str** with our title """ title = CONFIG['attr.graph.title'].get(self.stat_type(), '') title_stats = join(self._title_stats, ', ', width - len(title) - 4) return '%s (%s):' % (title, title_stats) if title_stats else title + ':'
def _draw_title(self, width, event_types, event_filter): """ Panel title with the event types we're logging and our regex filter if set. """ self.addstr(0, 0, ' ' * width) # clear line title_comp = list(nyx.log.condense_runlevels(*event_types)) if event_filter.selection(): title_comp.append('filter: %s' % event_filter.selection()) title_comp_str = join(title_comp, ', ', width - 10) title = 'Events (%s):' % title_comp_str if title_comp_str else 'Events:' self.addstr(0, 0, title, HIGHLIGHT)
def _draw_title(subwindow, event_types, event_filter): """ Panel title with the event types we're logging and our regex filter if set. """ subwindow.addstr(0, 0, ' ' * subwindow.width) # clear line title_comp = list(nyx.log.condense_runlevels(*event_types)) if event_filter.selection(): title_comp.append('filter: %s' % event_filter.selection()) title_comp_str = join(title_comp, ', ', subwindow.width - 10) title = 'Events (%s):' % title_comp_str if title_comp_str else 'Events:' subwindow.addstr(0, 0, title, HIGHLIGHT)