Skip to content

Instantly share code, notes, and snippets.

@SebastianJay
Last active April 2, 2017 05:37
Show Gist options
  • Save SebastianJay/8d1ded06a42fbe3e6ecfe636f1173a26 to your computer and use it in GitHub Desktop.
Save SebastianJay/8d1ded06a42fbe3e6ecfe636f1173a26 to your computer and use it in GitHub Desktop.
Prompt-based filtering
#! /bin/sh
python poison.py > candidates.txt && python filter_names.py
#! /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