Mercurial > hg > TextShaper
diff textshaper/onelineit.py @ 41:56199789d2a0
mv
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 25 Aug 2014 19:22:37 -0700 |
parents | onelineit.py@e1832eeae084 |
children | 1a80204bd562 |
line wrap: on
line diff
--- /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())