Last active
April 2, 2017 05:37
-
-
Save SebastianJay/8d1ded06a42fbe3e6ecfe636f1173a26 to your computer and use it in GitHub Desktop.
Prompt-based filtering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
python poison.py > candidates.txt && python filter_names.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
# 1. read names from infile | |
# 2. present a y/n prompt for each one | |
# 3. write all y's to outfile (with date stamp) | |
infile='candidates.txt' | |
outfile='poisoned-%s.txt' | |
import datetime | |
with open(infile, 'r') as f: | |
print 'For each prompt, press y for yes, anything else (i.e. just Return) for no.' | |
outlines=[] | |
for line in f: | |
line = line.strip() | |
if len(line) == 0: | |
continue | |
cmd = raw_input('Poison %s?: ' % line) | |
if cmd.strip().lower()[0:1] == 'y': | |
print 'Poisoned!' | |
outlines.append(line) | |
print 'All done. %d %s poisoned.' % (len(outlines), 'person' if len(outlines) == 1 else 'people') | |
with open(outfile % str(datetime.date.today()), 'w') as fout: | |
fout.write('\n'.join(outlines)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment