comparison textshaper/quote.py @ 25:a43d0ad17c29

STUB: textshaper/quote.py textshaper/split.py
author Jeff Hammel <k0scist@gmail.com>
date Sun, 23 Feb 2014 10:59:10 -0800
parents textshaper/split.py@4e00a2ce0a06
children c23782a7b7ba
comparison
equal deleted inserted replaced
24:0930c6884f8a 25:a43d0ad17c29
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 """
5 split some lines
6 """
7
8 import argparse
9 import os
10 import sys
11
12 def main(args=sys.argv[1:]):
13
14 parser = argparse.ArgumentParser(description=__doc__)
15 parser.add_argument('input', nargs='?',
16 type=argparse.FileType('r'), default=sys.stdin,
17 help='input file, or read from stdin if ommitted')
18 parser.add_argument('--quote', dest='quote',
19 action='store_true', default=False)
20 options = parser.parse_args(args)
21
22 read = options.input.read()
23
24 lines = read.strip().split()
25 if options.quote:
26 lines = ["'{}'".format(line) for line in lines]
27
28 print '\n'.join(lines)
29
30 if __name__ == '__main__':
31 main()