# HG changeset patch # User Jeff Hammel # Date 1391553887 28800 # Node ID 30f1781024a473234d23fb179fb6964881aac4c4 # Parent c3df7dccb02ba67fdac090abbc44e5efc81ba598 add splitline functionality diff -r c3df7dccb02b -r 30f1781024a4 split.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/split.py Tue Feb 04 14:44:47 2014 -0800 @@ -0,0 +1,31 @@ +#!/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()