示例#1
0
    def post_process(self, repo, **options):
        stats = [
            ('Total repository size [HDD]', filesizeformat(repo.size)),
            ('Total number of commits', len(repo)),
            ('Total number of branches', len(repo.branches)),
            ('Total number of tags', len(repo.tags)),
            ('Total number of authors', len(self.authors)),
            ('Avarage number of commits/author',
             float(len(repo)) / len(self.authors)),
            ('Avarage number of commits/day',
             float(len(repo)) / (self.last_date - self.start_date).days),
        ]
        if options['changeset_size']:
            stats.append(('Total size in all changesets',
                          filesizeformat(self.total_size)))

        max_label_size = max(len(label) for label, value in stats)
        output = ['']
        output.extend([
            '%s: %s' % (label.rjust(max_label_size + 3), value)
            for label, value in stats
        ])
        output.append('')
        output.append('')
        self.stdout.write(u'\n'.join(output))
示例#2
0
    def post_process(self, repo, **options):
        stats = [
            ('Total repository size [HDD]', filesizeformat(repo.size)),
            ('Total number of commits', len(repo)),
            ('Total number of branches', len(repo.branches)),
            ('Total number of tags', len(repo.tags)),
            ('Total number of authors', len(self.authors)),
            ('Avarage number of commits/author',
                float(len(repo)) / len(self.authors)),
            ('Avarage number of commits/day',
                float(len(repo)) / (self.last_date - self.start_date).days),
        ]
        if options['changeset_size']:
            stats.append(('Total size in all changesets',
                filesizeformat(self.total_size)))

        max_label_size = max(len(label) for label, value in stats)
        output = ['']
        output.extend([
            '%s: %s' % (label.rjust(max_label_size+3), value)
            for label, value in stats # pyflakes:ignore
        ])
        output.append('')
        output.append('')
        self.stdout.write(u'\n'.join(output))
示例#3
0
    def get_rendered_transfer(self, step=None, steps=None):
        if step is None:
            step = self.step
        if steps is None:
            steps = self.steps

        if steps <= 0:
            return '%s: -' % self.transfer_label
        total = filesizeformat(float(steps))
        if step <= 0:
            transferred = '-'
        else:
            transferred = filesizeformat(float(step))
        return '%s: %s / %s' % (self.transfer_label, transferred, total)
示例#4
0
    def get_rendered_transfer(self, step=None, steps=None):
        if step is None:
            step = self.step
        if steps is None:
            steps = self.steps

        if steps <= 0:
            return "%s: -" % self.transfer_label
        total = filesizeformat(float(steps))
        if step <= 0:
            transferred = "-"
        else:
            transferred = filesizeformat(float(step))
        return "%s: %s / %s" % (self.transfer_label, transferred, total)
示例#5
0
 def get_rendered_speed(self, step=None, total_seconds=None):
     if step is None:
         step = self.step
     if total_seconds is None:
         total_seconds = get_total_seconds(self.get_total_time())
     if step <= 0 or total_seconds <= 0:
         speed = "-"
     else:
         speed = filesizeformat(float(step) / total_seconds)
     return "%s: %s/s" % (self.speed_label, speed)
示例#6
0
 def get_rendered_speed(self, step=None, total_seconds=None):
     if step is None:
         step = self.step
     if total_seconds is None:
         total_seconds = get_total_seconds(self.get_total_time())
     if step <= 0 or total_seconds <= 0:
         speed = '-'
     else:
         speed = filesizeformat(float(step) / total_seconds)
     return '%s: %s/s' % (self.speed_label, speed)
示例#7
0
 def test_bytes(self):
     self.assertEqual(filesizeformat(10), '10 B')
示例#8
0
 def test_that_function_respects_sep_paramtere(self):
     self.assertEqual(filesizeformat(1, ''), '1B')
示例#9
0
 def test_gigabytes(self):
     self.assertEqual(filesizeformat(1024 * 1024 * 1024 * 12.92), '12.92 GB')
示例#10
0
 def test_megabytes(self):
     self.assertEqual(filesizeformat(1024 * 1024 * 2.3), '2.3 MB')
示例#11
0
 def test_kilobytes(self):
     self.assertEqual(filesizeformat(1024 * 2), '2 KB')
 def test_bytes(self):
     self.assertEqual(filesizeformat(10), '10 B')
 def test_that_function_respects_sep_paramtere(self):
     self.assertEqual(filesizeformat(1, ''), '1B')
 def test_gigabytes(self):
     self.assertEqual(filesizeformat(1024 * 1024 * 1024 * 12.92), '12.92 GB')
 def test_megabytes(self):
     self.assertEqual(filesizeformat(1024 * 1024 * 2.3), '2.3 MB')
 def test_kilobytes(self):
     self.assertEqual(filesizeformat(1024 * 2), '2 KB')