# HG changeset patch # User Jeff Hammel # Date 1409019757 25200 # Node ID 56199789d2a08065c7f63902305240e7cb61ed98 # Parent e1832eeae0842333ab277a56068d3731750a242b mv diff -r e1832eeae084 -r 56199789d2a0 onelineit.py --- 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()) diff -r e1832eeae084 -r 56199789d2a0 textshaper/onelineit.py --- /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())