-
Notifications
You must be signed in to change notification settings - Fork 1
/
filter.py
executable file
·44 lines (40 loc) · 1.11 KB
/
filter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/python
import getopt
import sys
# Our modules
import spamTest
import spamParse
import spamdb
def usage():
print "-h,--help Print this Help Message"
print "-t,--train Train on a message read from file"
print "-f,--file= The file to analyse"
print ""
print "The program will print out the spam value of an email"
print "spaminess in order for a shell script to determine it."
def main():
try:
opts, args = getopt.getopt(sys.argv[1:], "htf:y",
["help", "train", "file=", "yes"])
except getopt.GetoptError as err:
# print help information and exit:
print str(err)
usage()
sys.exit(2)
# iterate over the prog args
for o, a in opts:
if o == "-t":
training = True
elif o in ("-h", "--help"):
usage()
sys.exit()
elif o in ("-f", "--file"):
fileName = a
elif o in ("-y", "--yes"):
isSpam = True
else:
assert False, "unhandled option"
# begin program init
spamdb.initSpamDb()
if __name__ == "__main__":
main()