Skip to content

Commit

Permalink
Simplify collection_reports
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorbin committed Aug 6, 2012
1 parent 3155493 commit 118d9fe
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions means.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,12 @@ def collection_stats(collection):
yield field, mean

def collection_report(collection):
s = ''
fields = list(collection_stats(collection))
maxlen = max(len(label) for label, _ in fields)
maxlen += 2
for field, mean in fields:
s += (field + ':').ljust(maxlen)
if isinstance(mean, float):
s += str(mean).rstrip('.0') or '0'
else:
s += str(mean)
s += '\n'
return s.rstrip('\n')
return '\n'.join(
(field + ':').ljust(maxlen) + str(mean)
for field, mean in fields)

def maybe_path_exists(f):
@wraps(f)
Expand Down

0 comments on commit 118d9fe

Please sign in to comment.