Mercurial > hg > TextShaper
view textshaper/split.py @ 24:0930c6884f8a
STUB: README.txt setup.py textshaper/indent.py
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 23 Feb 2014 10:57:19 -0800 |
parents | 4e00a2ce0a06 |
children |
line wrap: on
line source
#!/usr/bin/env python # -*- coding: utf-8 -*- """ split some lines """ import argparse import os import sys def main(args=sys.argv[1:]): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('input', nargs='?', type=argparse.FileType('r'), default=sys.stdin, help='input file, or read from stdin if ommitted') parser.add_argument('--quote', dest='quote', action='store_true', default=False) options = parser.parse_args(args) read = options.input.read() lines = read.strip().split() if options.quote: lines = ["'{}'".format(line) for line in lines] print '\n'.join(lines) if __name__ == '__main__': main()