def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "shc", 
                            ["help", "train-spam", "train-ham", "check"])
        if len(opts) == 0 or len(args) == 0:
            raise getopt.error("no options or argumens")
    except getopt.error, msg:
        print(msg)
        usage()
        sys.exit(2)

    storage = Storage(args[0])
    try:
        storage.load()
    except __HOLE__:
        print("Creating database")
    bayes = Bayes(storage)
    # process options
    for o, a in opts:
        if o in ("--help", ""):
            usage()
            sys.exit(0)
        elif o in ("-s", "--train-spam"):
            bayes.train(sys.stdin.read(), True)
            print("Trained as spam")
        elif o in ("-h", "--train-ham"):
            bayes.train(sys.stdin.read(), False)
            print("Trained as ham")
        elif o in ("-c", "--check"):
            print("%.2f" % bayes.spam_rating(sys.stdin.read()))
        else:
            assert False, "unhandled option"
    storage.finish()
dataset/ETHPy150Open dchest/pybayesantispam/bayes.py/main