comparison textshaper/main.py @ 12:5b70bbff04b1

STUB: textshaper/main.py
author Jeff Hammel <k0scist@gmail.com>
date Sat, 25 Jan 2014 18:09:48 -0800
parents 71fb16088d54
children c3df7dccb02b
comparison
equal deleted inserted replaced
11:0d0db0d79bfd 12:5b70bbff04b1
9 import os 9 import os
10 import subprocess 10 import subprocess
11 import sys 11 import sys
12 import time 12 import time
13 13
14 def display(content): 14 def info(content):
15 """gathers info about the content and returns a dict"""
16 lines = content.splitlines()
17 return {'lines': len(lines),
18 'chars': len(content),
19 'columns': max([len(line) for line in lines])
20 }
21
22 def display(content, keys=('lines', 'chars', 'columns'), hr='--'):
15 print content 23 print content
16 print '--' 24 if keys:
17 nlines = len(content.splitlines()) 25 _info = info(content)
18 print '%d lines' % nlines 26 print (hr)
27 print ('; '.join(['{}: {}'.format(key, _info[key])
28 for key in keys])
19 29
20 def add_options(parser): 30 def add_options(parser):
21 """add options to the OptionParser instance""" 31 """add options to the OptionParser instance"""
22 32
23 # TODO 33 # TODO