# HG changeset patch # User Jeff Hammel # Date 1477696284 25200 # Node ID 8275fa887f2b056edaf6a72802d84b3bb8b0e1f8 # Parent dbd2562cb03efa8685822b8bdd66f87acc3a30bc cleanup + renaming diff -r dbd2562cb03e -r 8275fa887f2b python/cgiescape.py --- 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()) - diff -r dbd2562cb03e -r 8275fa887f2b python/count.py --- 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)))) diff -r dbd2562cb03e -r 8275fa887f2b python/example/cgiescape.py --- /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()) + diff -r dbd2562cb03e -r 8275fa887f2b python/example/find_str_format.py --- /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() diff -r dbd2562cb03e -r 8275fa887f2b python/find_str_format.py --- 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()