<commit_before>import sys

from finance import db
from finance.models.auth import AuthUser


def create_db(args):
    print("Creating database...")
    db.create_all()
    print("done.")


def create_user(args):
    print("Creating user...")
    username = args[0] if len(args) > 0 else 'admin'
    password = args[1] if len(args) > 1 else '<PASSWORD>'
    u = AuthUser(username, password)
    db.session.add(u)
    db.session.commit()
    print("done.")


COMMANDS = {
    'initdb': create_db,
    'user': create_user,
}

if __name__ == "__main__":
    try:
        cmd = sys.argv[1]
    except KeyError:
        print("Missing required command\n")
        sys.exit(1)
    else:
        COMMANDS[cmd](sys.argv[2:])<commit_msg>added load data command to setup account types<commit_after>import sys

from finance import db
from finance.models.auth import AuthUser
from finance.models.account import Account
from finance.models.account_type import AccountType


def create_db(args):
    print("Creating database...")
    db.create_all()
    print("done.")


def create_user(args):
    print("Creating user...")
    username = args[0] if len(args) > 0 else 'admin'
    password = args[1] if len(args) > 1 else '<PASSWORD>'
    u = AuthUser(username, password)
    db.session.add(u)
    db.session.commit()
    print("done.")


def load_default_data(args):
    print("Loading default data...")

    # load account types
    asset = AccountType('Assets')
    liability = AccountType('Liability')
    income = AccountType('Income')
    expense = AccountType('Expense')
    db.session.add(asset)
    db.session.add(liability)
    db.session.add(income)
    db.session.add(expense)
    db.session.commit()
    print("done.")


COMMANDS = {
    'initdb': create_db,
    'user': create_user,
    'loaddata': load_default_data,
}

if __name__ == "__main__":
    try:
        cmd = sys.argv[1]
    except KeyError:
        print("Missing required command\n")
        sys.exit(1)
    else:
        COMMANDS[cmd](sys.argv[2:])
{'fraction_non_alphanumeric': 0.13817097415506957, 'fraction_numerical': 0.006958250497017893, 'mean_word_length': 3.091463414634146, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '6562430', 'n_tokens_mistral': 669, 'n_tokens_neox': 654, 'n_words': 156}