diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/signature.py	Thu Oct 15 11:41:26 2009 -0400
@@ -0,0 +1,30 @@
+import random
+import sys
+import time
+
+from optparse import OptionParser
+
+parser = OptionParser()
+parser.add_option('-f', '--file')
+parser.add_option('-o', '--output')
+(options, args) = parser.parse_args()
+
+if options.file:
+    f = file(options.file)    
+else:
+    f = sys.stdin
+
+lines = [ line.strip() or '\n' for line in f.read().strip().split('\n') ]
+content = '\n'.join(lines)
+fortunes = [i.strip() for i in content.split('\n\n') ]
+f.close()
+
+while 1:
+    if options.output:
+        f = file(sig, 'w')
+        print >> f, random.choice(fortunes)
+        f.close()
+    else:
+        print random.choice(fortunes)
+    time.sleep(1)
+