# HG changeset patch # User Jeff Hammel # Date 1409793195 25200 # Node ID 21b6a9569f21426f6b9030eec6b755d63339732d # Parent 1a80204bd5623b605fda391277bcb0f8e894a4ac onelineit diff -r 1a80204bd562 -r 21b6a9569f21 textshaper/main.py --- a/textshaper/main.py Mon Aug 25 19:31:16 2014 -0700 +++ b/textshaper/main.py Wed Sep 03 18:13:15 2014 -0700 @@ -12,6 +12,7 @@ import time from .commands import Commands from .indent import deindent, indent +from .onelineit import onelineit from .tablify import make_csv from .whitespace import underscore from which import which @@ -41,6 +42,7 @@ commands = Commands() commands.add(indent, 'i') commands.add(deindent, 'd') + commands.add(onelineit, 'o') commands.add(underscore, 'u') commands.add(make_csv, 'c') return commands diff -r 1a80204bd562 -r 21b6a9569f21 textshaper/onelineit.py --- a/textshaper/onelineit.py Mon Aug 25 19:31:16 2014 -0700 +++ b/textshaper/onelineit.py Wed Sep 03 18:13:15 2014 -0700 @@ -5,17 +5,18 @@ """ import sys +from .decorator import lines +@lines def onelineit(string): """make a string one line""" - string = string.split('\n') string = [ i.strip() or '\n' for i in string ] string = ' '.join(string) string = string.split('\n') string = [ i.strip() for i in string if i.strip() ] - return '\n\n'.join(string) + return '\n\n'.join(string).splitlines() def main(args=sys.argv[1:]): """CLI"""