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))
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))
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)
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)
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)
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)
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')