# HG changeset patch # User Jeff Hammel # Date 1390702188 28800 # Node ID 5b70bbff04b15f2512b407fbde63a6d8d5d4d279 # Parent 0d0db0d79bfdadd096de98ed33be06434b8ad374 STUB: textshaper/main.py diff -r 0d0db0d79bfd -r 5b70bbff04b1 textshaper/main.py --- a/textshaper/main.py Sat Jan 18 09:31:05 2014 -0800 +++ b/textshaper/main.py Sat Jan 25 18:09:48 2014 -0800 @@ -11,11 +11,21 @@ import sys import time -def display(content): +def info(content): + """gathers info about the content and returns a dict""" + lines = content.splitlines() + return {'lines': len(lines), + 'chars': len(content), + 'columns': max([len(line) for line in lines]) + } + +def display(content, keys=('lines', 'chars', 'columns'), hr='--'): print content - print '--' - nlines = len(content.splitlines()) - print '%d lines' % nlines + if keys: + _info = info(content) + print (hr) + print ('; '.join(['{}: {}'.format(key, _info[key]) + for key in keys]) def add_options(parser): """add options to the OptionParser instance"""