Exemplo n.º 1
0
  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))
Exemplo n.º 2
0
  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
Exemplo n.º 3
0
  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
Exemplo n.º 4
0
  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 + ':'
Exemplo n.º 5
0
  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 + ':'
Exemplo n.º 6
0
Arquivo: log.py Projeto: patacca/nyx
  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)
Exemplo n.º 7
0
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)