annotate textshaper/split.py @ 23:7ffe000f6f42

removing stub
author Jeff Hammel <k0scist@gmail.com>
date Sun, 23 Feb 2014 10:14:06 -0800
parents 4e00a2ce0a06
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 """
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 split some lines
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6 """
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8 import argparse
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 import os
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 import sys
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 def main(args=sys.argv[1:]):
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 parser = argparse.ArgumentParser(description=__doc__)
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15 parser.add_argument('input', nargs='?',
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 type=argparse.FileType('r'), default=sys.stdin,
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 help='input file, or read from stdin if ommitted')
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18 parser.add_argument('--quote', dest='quote',
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 action='store_true', default=False)
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20 options = parser.parse_args(args)
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22 read = options.input.read()
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
24 lines = read.strip().split()
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
25 if options.quote:
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
26 lines = ["'{}'".format(line) for line in lines]
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
27
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
28 print '\n'.join(lines)
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
29
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
30 if __name__ == '__main__':
30f1781024a4 add splitline functionality
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
31 main()