Last active
February 13, 2017 20:41
-
-
Save jeffa/8be892b3c0e8d14a729dd0d1628951ae to your computer and use it in GitHub Desktop.
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/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