Skip to content

Instantly share code, notes, and snippets.

@jeffa
Last active February 13, 2017 20:41
Show Gist options
  • Save jeffa/8be892b3c0e8d14a729dd0d1628951ae to your computer and use it in GitHub Desktop.
Save jeffa/8be892b3c0e8d14a729dd0d1628951ae to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import re, sys
limit = 2
key = 'none'
file = open( sys.argv[1], 'r' )
message = file.read()
tokens = message.split()
buckets = { 'what': [], 'why': [], key: [] }
for token in tokens:
t = token.lower()
if t == 'what:' or t == 'why:':
key = t[:-1]
else:
buckets[key].append( token )
if len( buckets['what'] ) < limit or len( buckets['why'] ) < limit:
print( "[POLICY] Your message is not sufficiently meaningful" )
sys.exit( 1 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment