Mercurial > hg > TextShaper
changeset 37:8cf9a26b9aaa
STUB: textshaper/main.py textshaper/tablify.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 12 May 2014 10:29:06 -0700 |
parents | 55e0579e2143 |
children | 56fa70e2e239 |
files | textshaper/main.py textshaper/tablify.py |
diffstat | 2 files changed, 15 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/textshaper/main.py Sat May 03 14:47:16 2014 -0700 +++ b/textshaper/main.py Mon May 12 10:29:06 2014 -0700 @@ -12,6 +12,7 @@ import time from .commands import Commands from .indent import deindent, indent +from .tablify import make_csv from .whitespace import underscore from which import which @@ -41,6 +42,7 @@ commands.add(indent, 'i') commands.add(deindent, 'd') commands.add(underscore, 'u') + commands.add(make_csv, 'c') return commands
--- a/textshaper/tablify.py Sat May 03 14:47:16 2014 -0700 +++ b/textshaper/tablify.py Mon May 12 10:29:06 2014 -0700 @@ -1,3 +1,16 @@ +""" +functions having to do with tables +""" + +import csv +from .decorator import lines +from StringIO import StringIO + +@lines +def make_csv(text): + """make space-separated text into comma-separated""" + return [','.join(line.strip().split()) for line in text] + def format_cols(rows, header=None, right_align=()): if header: raise NotImplementedError('TODO') # -> record TODO items