comparison python/signature.py @ 0:f3ab51c79813

adding configuration from https://svn.openplans.org/svn/config_jhammel/
author k0s <k0scist@gmail.com>
date Thu, 15 Oct 2009 11:41:26 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f3ab51c79813
1 import random
2 import sys
3 import time
4
5 from optparse import OptionParser
6
7 parser = OptionParser()
8 parser.add_option('-f', '--file')
9 parser.add_option('-o', '--output')
10 (options, args) = parser.parse_args()
11
12 if options.file:
13 f = file(options.file)
14 else:
15 f = sys.stdin
16
17 lines = [ line.strip() or '\n' for line in f.read().strip().split('\n') ]
18 content = '\n'.join(lines)
19 fortunes = [i.strip() for i in content.split('\n\n') ]
20 f.close()
21
22 while 1:
23 if options.output:
24 f = file(sig, 'w')
25 print >> f, random.choice(fortunes)
26 f.close()
27 else:
28 print random.choice(fortunes)
29 time.sleep(1)
30