changeset 800:8275fa887f2b

cleanup + renaming
author Jeff Hammel <k0scist@gmail.com>
date Fri, 28 Oct 2016 16:11:24 -0700
parents dbd2562cb03e
children bea4dd61ae45
files python/cgiescape.py python/count.py python/example/cgiescape.py python/example/find_str_format.py python/find_str_format.py
diffstat 5 files changed, 45 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/python/cgiescape.py	Fri Oct 28 16:06:11 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-#!/usr/bin/env python
-
-import sys
-import cgi
-
-print cgi.escape(sys.stdin.read())
-
--- a/python/count.py	Fri Oct 28 16:06:11 2016 -0700
+++ b/python/count.py	Fri Oct 28 16:11:24 2016 -0700
@@ -58,7 +58,12 @@
     options = parser.parse_args(args)
 
     # read a thing
-    items = options.input.read().strip().split()
+    try:
+        items = options.input.read().strip().split()
+    except KeyboardInterrupt:
+        # probably trying to read stdin interactively
+        # revert! revert! revert!
+        return
 
     if options.duplicates:
         print ('\n'.join(sorted(duplicates(*items))))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/example/cgiescape.py	Fri Oct 28 16:11:24 2016 -0700
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+import sys
+import cgi
+
+print cgi.escape(sys.stdin.read())
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/python/example/find_str_format.py	Fri Oct 28 16:11:24 2016 -0700
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+"""
+find str format options
+"""
+
+import argparse
+import os
+import subprocess
+import sys
+
+__all__ = ['main']
+
+def find_keys(string):
+    retval = set()
+    while True:
+        try:
+            string.format(**{i:'' for i in retval})
+            return retval
+        except KeyError as e:
+            retval.add(e.message)
+
+
+def main(args=sys.argv[1:]):
+
+    string = ' '.join(args)
+    keys = find_keys(string)
+    print ('\n'.join(sorted(keys)))
+
+if __name__ == '__main__':
+    main()
--- a/python/find_str_format.py	Fri Oct 28 16:06:11 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-
-"""
-find str format options
-"""
-
-import argparse
-import os
-import subprocess
-import sys
-
-__all__ = ['main']
-
-def find_keys(string):
-    retval = set()
-    while True:
-        try:
-            string.format(**{i:'' for i in retval})
-            return retval
-        except KeyError as e:
-            retval.add(e.message)
-
-
-def main(args=sys.argv[1:]):
-
-    string = ' '.join(args)
-    keys = find_keys(string)
-    print ('\n'.join(sorted(keys)))
-
-if __name__ == '__main__':
-    main()