Mercurial > hg > TextShaper
changeset 41:56199789d2a0
mv
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 25 Aug 2014 19:22:37 -0700 |
parents | e1832eeae084 |
children | 1a80204bd562 |
files | onelineit.py textshaper/onelineit.py |
diffstat | 2 files changed, 14 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/onelineit.py Fri Aug 22 15:54:19 2014 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#!/usr/bin/env python - -def onelineit(string): - 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) - -if __name__ == '__main__': - import sys - print onelineit(sys.stdin.read())
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/textshaper/onelineit.py Mon Aug 25 19:22:37 2014 -0700 @@ -0,0 +1,14 @@ +#!/usr/bin/env python + +def onelineit(string): + 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) + +if __name__ == '__main__': + import sys + print onelineit(sys.stdin.read())