Mercurial > hg > config
comparison python/count.py @ 800:8275fa887f2b
cleanup + renaming
| author | Jeff Hammel <k0scist@gmail.com> |
|---|---|
| date | Fri, 28 Oct 2016 16:11:24 -0700 |
| parents | 25622fb5906d |
| children |
comparison
equal
deleted
inserted
replaced
| 799:dbd2562cb03e | 800:8275fa887f2b |
|---|---|
| 56 # parse command line options | 56 # parse command line options |
| 57 parser = CountParser() | 57 parser = CountParser() |
| 58 options = parser.parse_args(args) | 58 options = parser.parse_args(args) |
| 59 | 59 |
| 60 # read a thing | 60 # read a thing |
| 61 items = options.input.read().strip().split() | 61 try: |
| 62 items = options.input.read().strip().split() | |
| 63 except KeyboardInterrupt: | |
| 64 # probably trying to read stdin interactively | |
| 65 # revert! revert! revert! | |
| 66 return | |
| 62 | 67 |
| 63 if options.duplicates: | 68 if options.duplicates: |
| 64 print ('\n'.join(sorted(duplicates(*items)))) | 69 print ('\n'.join(sorted(duplicates(*items)))) |
| 65 else: | 70 else: |
| 66 # get the counts | 71 # get the counts |
