Mercurial > hg > TextShaper
view textshaper/onelineit.py @ 57:a2bbe406f570 default tip
which is no longer maintained; roll our mediocre own
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Mon, 20 Feb 2017 10:40:34 -0800 |
parents | 21b6a9569f21 |
children |
line wrap: on
line source
#!/usr/bin/env python """ make a string one line """ import sys from .decorator import lines @lines def onelineit(string): """make a string one line""" 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).splitlines() def main(args=sys.argv[1:]): """CLI""" print (onelineit(sys.stdin.read())) if __name__ == '__main__': main()