<commit_before>import sys
import json
from value_bot import ValueBot
from flask import Flask, request
from db.db import init_db

app = Flask(__name__)
app.config.from_pyfile('./config.py')

def trigger_list():
    hashtags = app.config["HASHTAGS"]
    triggers = {"valuebot"}

    for value in hashtags:
        for hashtag in hashtags[value]:
            triggers.add(hashtag)

    return ','.join(triggers)

def payload(text):
    return {
        "text": text,
        'link_names': 1
    }

value_bot = ValueBot(
    admins=app.config["ADMINS"],
    hashtags=app.config["HASHTAGS"],
    webhook_url=app.config["WEBHOOK_URL"])

@app.route('/', methods=['POST'])
def post():
    to_return = value_bot.handle_incoming_message(request.form)

    return json.dumps(payload(to_return))

def main():
    args = sys.argv
    port = 4567
    if len(args) == 2:
        try:
            port = int(args[1])
        except ValueError:
            print "Invalid port specified, defaulting to {}".format(port)

    app.run(host='0.0.0.0', port=port, debug=True)

if __name__ == "__main__":
    main()<commit_msg>Switched arg parsing to argparse<commit_after>import argparse
import json
from value_bot import ValueBot
from flask import Flask, request
from db.db import init_db

app = Flask(__name__)
app.config.from_pyfile('./config.py')

def trigger_list():
    hashtags = app.config["HASHTAGS"]
    triggers = {"valuebot"}

    for value in hashtags:
        for hashtag in hashtags[value]:
            triggers.add(hashtag)

    return ','.join(triggers)

def payload(text):
    return {
        "text": text,
        'link_names': 1
    }

value_bot = ValueBot(
    admins=app.config["ADMINS"],
    hashtags=app.config["HASHTAGS"],
    webhook_url=app.config["WEBHOOK_URL"])

@app.route('/', methods=['POST'])
def post():
    to_return = value_bot.handle_incoming_message(request.form)

    return json.dumps(payload(to_return))

def main():
    parser = argparse.ArgumentParser(description="ValueBot: a SlackBot for your company's values")
    parser.add_argument('-p', '--port', type=int, help='the port to run ValueBot on')
    args = parser.parse_args()

    if args.port:
        port = args.port
    else:
        port = 4567

    app.run(host='0.0.0.0', port=port, debug=True)

if __name__ == "__main__":
    main()
{'fraction_non_alphanumeric': 0.13595166163141995, 'fraction_numerical': 0.008631851532153647, 'mean_word_length': 3.268876611418048, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6967706', 'n_tokens_mistral': 809, 'n_tokens_neox': 781, 'n_words': 180}