view textshaper/onelineit.py @ 42:1a80204bd562

basic cli
author Jeff Hammel <k0scist@gmail.com>
date Mon, 25 Aug 2014 19:31:16 -0700
parents 56199789d2a0
children 21b6a9569f21
line wrap: on
line source

#!/usr/bin/env python

"""
make a string one line
"""

import sys

def onelineit(string):
    """make a string one line"""

    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)

def main(args=sys.argv[1:]):
    """CLI"""
    print (onelineit(sys.stdin.read()))

if __name__ == '__main__':
    main()