<commit_before># Runs both locally (using python index.py) and on WebFaction

import random
import sys
import os

from flask_sqlalchemy import SQLAlchemy

CURRENT_FILE = os.path.abspath(__file__)
CURRENT_DIR = os.path.dirname(CURRENT_FILE)
PROJECT_DIR = os.path.dirname(CURRENT_DIR)

# For WebFaction, should be ignored locally
sys.path.append(PROJECT_DIR + '/virtualenv/lib/python3.5/site-packages/')
sys.path.append(PROJECT_DIR + '/src/')
sys.path.append(PROJECT_DIR + '/src/app/')

from app import app

db = SQLAlchemy(app)

from app.models import Name, NameFrequency

def create_test_data():

    # Create the tables, if not done yet
    try:
        db.create_all()
    except:
        pass

    db.session.query(NameFrequency).delete()
    db.session.query(Name).delete()
    db.session.commit()
    for name in ('Fred', 'Sue'):
        new_name = Name(name=name)
        db.session.add(new_name)
        for year in range(1990, 1996):
            new_frequency = NameFrequency(
                name=new_name,
                year=year,
                boys_count=random.randint(50, 100),
                girls_count=random.randint(50, 100))
    db.session.commit()

if __name__ == '__main__':
    create_test_data()
<commit_msg>Get create_test_data to run on WebFaction<commit_after># Runs both locally (using python index.py) and on WebFaction

# On WebFaction, must be run after activating the virtualenv

import random

from app import db

from app.models import Name, NameFrequency

def create_test_data():

    # Create the tables, if not done yet
    try:
        db.create_all()
    except:
        pass

    db.session.query(NameFrequency).delete()
    db.session.query(Name).delete()
    db.session.commit()
    for name in ('Fred', 'Sue'):
        new_name = Name(name=name)
        db.session.add(new_name)
        for year in range(1990, 1996):
            new_frequency = NameFrequency(
                name=new_name,
                year=year,
                boys_count=random.randint(50, 100),
                girls_count=random.randint(50, 100))
    db.session.commit()

if __name__ == '__main__':
    create_test_data()

{'fraction_non_alphanumeric': 0.10582750582750583, 'fraction_numerical': 0.017715617715617717, 'mean_word_length': 2.7848324514991183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1832101', 'n_tokens_mistral': 726, 'n_tokens_neox': 672, 'n_words': 168}