예제 #1
0
  def oneline(self, cols, annotate_ownership):
    colstrings = []
    for col in cols:
      if not col['visible']:
        continue

      w = col['width']
      id = col['id']
      if id == 'id':
        colstrings.append(misc.chop(self.id, w))
      elif id == 'type':
        colstrings.append(misc.pad_to_length(self.type, w))
      elif id == 'date':
        colstrings.append(misc.pad_to_length('%s/%s' % (self.date.month, self.date.day), w))
      elif id == 'title':
        if not annotate_ownership or self.assigned_to == '-':
          colstrings.append('%s%s%s' % (colors.colors[self.status_colors[self.status]],        \
                                        misc.pad_to_length(misc.chop(self.title, w, '..'), w), \
	                    colors.colors['default']))
        else:
          name_suffix = ' (%s)' % self.assigned_to
          w = w - len(name_suffix)
          colstrings.append('%s%s' % (misc.pad_to_length(misc.chop(self.title, w, '..'), w), \
                                      name_suffix))
      elif id == 'status':
        colstrings.append('%s%s%s' % (colors.colors[self.status_colors[self.status]],        \
                                      misc.pad_to_length(self.status, 8),                             \
	                  colors.colors['default']))
      elif id == 'priority':
        priostr = self.prio_names[self.prio-1]
        colstrings.append('%s%s%s' % (colors.colors[self.prio_colors[priostr]],              \
                                      priostr,                                               \
	                  colors.colors['default']))

    return ' '.join(colstrings)
예제 #2
0
  def oneline(self, cols, annotate_ownership):
    colstrings = []
    for col in cols:
      if not col['visible']:
        continue

      w = col['width']
      id = col['id']
      if id == 'id':
        colstrings.append(misc.chop(self.id, w))
      elif id == 'type':
        colstrings.append(misc.pad_to_length(self.type, w))
      elif id == 'date':
        colstrings.append(misc.pad_to_length('%s/%s' % (self.date.month, self.date.day), w))
      elif id == 'title':
        title = self.title
        if self.assigned_to != '-' and annotate_ownership:
          name_suffix = ' (%s)' % self.assigned_to.split()[0]
          w = w - len(name_suffix)
          title = '%s%s' % (misc.pad_to_length(misc.chop(title, w, '..'), w), name_suffix)
        else:
          title = misc.pad_to_length(misc.chop(title, w, '..'), w)
        colstrings.append('%s%s%s' % (colors.colors[self.status_colors[self.status]],        \
                                      title, \
                                      colors.colors['default']))
      elif id == 'status':
        colstrings.append('%s%s%s' % (colors.colors[self.status_colors[self.status]],        \
                                      misc.pad_to_length(self.status, 8),                             \
	                  colors.colors['default']))
      elif id == 'prio':
        priostr = self.prio_names[self.prio-1]
        colstrings.append('%s%s%s' % (colors.colors[self.prio_colors[priostr]],              \
                                      misc.pad_to_length(priostr, 4),
	                  colors.colors['default']))
      elif id == 'wght':
        weightstr = self.weight_names[min(3, max(0, int(round(math.log(self.weight, 3)))))]
        colstrings.append(misc.pad_to_length(weightstr, 5))
      elif id == 'hours':
		colstrings.append(misc.pad_to_length(self.devtime, w))

    return ' '.join(colstrings)
예제 #3
0
    def __print_ticket_rows(self, rel, tickets, show_types, show_progress_bar,
                            annotate_ownership):
        print_count = 0

        # Get the available terminal drawing space
        try:
            width, _ = os.get_terminal_size()
        except Exception:
            _, width = os.popen('stty size').read().strip().split()
            width = int(width)

        total = sum([t.weight
                     for t in tickets if t.status != 'rejected']) * 1.0
        done = sum([
            t.weight
            for t in tickets if t.status not in ['open', 'rejected', 'test']
        ]) * 1.0
        release_line = colors.colors['red-on-white'] + '%-16s' % rel + \
                                                                                                         colors.colors['default']

        # Show a progress bar only when there are items in this release
        if total > 0 and show_progress_bar:
            header = release_line + self.progress_bar(done / total)
        else:
            header = release_line

        # First, filter all types that do not need to be shown out of the list
        tickets_to_print = filter(lambda t: t.status in show_types, tickets)
        if len(tickets_to_print) > 0:
            print(header)

            # Then, sort the tickets by date modified
            tickets_to_print.sort(cmp_by_prio_then_date)

            # ...and finally, print them
            hide_status = show_types == ['open']
            cols = [
                {
                    'id': 'id',
                    'width': 7,
                    'visible': True
                },
                {
                    'id': 'type',
                    'width': 7,
                    'visible': True
                },
                {
                    'id': 'title',
                    'width': 0,
                    'visible': True
                },
                {
                    'id': 'wght',
                    'width': 5,
                    'visible': not hide_status
                },
                {
                    'id': 'status',
                    'width': 8,
                    'visible': not hide_status
                },
                {
                    'id': 'date',
                    'width': 10,
                    'visible': True
                },
                {
                    'id': 'prio',
                    'width': 4,
                    'visible': True
                },
            ]

            # Calculate the real value for the zero-width column
            # Assumption here is that there is only 1 zero-width column
            visible_colwidths = map(lambda c: c['width'],
                                    filter(lambda c: c['visible'], cols))
            total_width = sum(visible_colwidths) + len(visible_colwidths)
            for col in cols:
                if col['width'] == 0:
                    col['width'] = max(0, width - total_width)

            colstrings = []
            for col in cols:
                if not col['visible']:
                    continue
                colstrings.append(misc.pad_to_length(col['id'], col['width']))

            print(colors.colors['blue-on-white'] \
                    + ' '.join(colstrings) \
                    + colors.colors['default']
            )

            for t in tickets_to_print:
                print_count += 1
                print(t.oneline(cols, annotate_ownership))

            print('')
        else:
            pass

        return print_count
예제 #4
0
파일: gitit.py 프로젝트: dongrote/git-it
    def __print_ticket_rows(self, rel, tickets, show_types, show_progress_bar, annotate_ownership):
        print_count = 0

        # Get the available terminal drawing space
        if os.isatty(sys.stdout.fileno()):
            _, width = os.popen('stty size').read().strip().split()
            width = int(width)
        else:
            width = 80

        total = sum([t.weight for t in tickets if t.status != 'rejected']) * 1.0
        done = sum([t.weight for t in tickets if t.status not in ['open', 'rejected', 'test']]) * 1.0
        release_line = colors.colors['red-on-white'] + '%-16s' % rel + \
                                                                                                         colors.colors['default']

        # Show a progress bar only when there are items in this release
        if total > 0 and show_progress_bar:
            header = release_line + self.progress_bar(done / total)
        else:
            header = release_line

        # First, filter all types that do not need to be shown out of the list
        tickets_to_print = filter(lambda t: t.status in show_types, tickets)
        if len(tickets_to_print) > 0:
            print header

            # Then, sort the tickets by date modified
            tickets_to_print.sort(cmp_by_prio_then_date)

            # ...and finally, print them
            hide_status = show_types == [ 'open' ]
            cols = [ { 'id': 'id',             'width': 7, 'visible': True },
                             { 'id': 'type',         'width': 7, 'visible': True },
                             { 'id': 'title',        'width': 0, 'visible': True },
                             { 'id': 'wght',         'width': 5, 'visible': not hide_status },
                             { 'id': 'status',     'width': 8, 'visible': not hide_status },
                             { 'id': 'date',         'width': 6, 'visible': True },
                             { 'id': 'prio',         'width': 4, 'visible': True },
                             { 'id': 'hours',        'width': 6, 'visible': True },
                         ]

            # Calculate the real value for the zero-width column
            # Assumption here is that there is only 1 zero-width column
            visible_colwidths = map(lambda c: c['width'], filter(lambda c: c['visible'], cols))
            total_width = sum(visible_colwidths) + len(visible_colwidths)
            for col in cols:
                if col['width'] == 0:
                    col['width'] = max(0, width - total_width)

            colstrings = []
            for col in cols:
                if not col['visible']:
                    continue
                colstrings.append(misc.pad_to_length(col['id'], col['width']))

            print colors.colors['blue-on-white'] + \
                        ' '.join(colstrings) +                     \
                        colors.colors['default']

            for t in tickets_to_print:
                print_count += 1
                print t.oneline(cols, annotate_ownership)

            print ''
        else:
            pass

        return print_count