Mercurial > hg > TextShaper
comparison onelineit.py @ 40:e1832eeae084
from http://k0s.org/hg/config
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Fri, 22 Aug 2014 15:54:19 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
39:986f8a20c234 | 40:e1832eeae084 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 def onelineit(string): | |
4 string = string.split('\n') | |
5 string = [ i.strip() or '\n' for i in string ] | |
6 string = ' '.join(string) | |
7 string = string.split('\n') | |
8 string = [ i.strip() for i in string if i.strip() ] | |
9 | |
10 return '\n\n'.join(string) | |
11 | |
12 if __name__ == '__main__': | |
13 import sys | |
14 print onelineit(sys.stdin.read()) |