<commit_before>import json
import random
import os.path
import logging

import sanic
import websockets


from bogoapp import bogo_manager
from bogoapp import tools
from bogoapp import settings
from bogoapp import db
from bogoapp import html


logger = logging.getLogger("WebSocketManager")


def make_sanic(name):
    app = sanic.Sanic(name)
    app.config["LOGO"] = settings.LOGO
    app.static("main.js", "./main.js")
    return app


def make_bogo_manager():
    min_stop = settings.MINIMUM_SEQUENCE_STOP
    max_stop = settings.MAXIMUM_SEQUENCE_STOP
    sort_limit = getattr(settings, "SORT_LIMIT", 0)
    unsorted_lists = tools.unsorted_lists(min_stop, max_stop, sort_limit)

    speed_resolution = getattr(settings, "SPEED_RESOLUTION", 1)

    random_module = random.Random()
    random_module.seed(settings.RANDOM_SEED)

    dns = settings.ODBC_DNS
    schema = settings.SQL_SCHEMA_PATH
    database = db.Database(dns, schema)
    if not os.path.exists(settings.DATABASE_PATH):
        database.init()

    return bogo_manager.BogoManager(
            unsorted_lists, speed_resolution
            database, random_module)


def make_websocket_app(sanic_app):

    class WebSocketManager:

        def __init__(self):
            self.spectators = 0

        @sanic_app.websocket("/feed")
        async def feed(self, request, ws):
            logger.info("init ws feed")<commit_msg>fix typo<commit_after>import json
import random
import os.path
import logging

import sanic
import websockets


from bogoapp import bogo_manager
from bogoapp import tools
from bogoapp import settings
from bogoapp import db
from bogoapp import html


logger = logging.getLogger("WebSocketManager")


def make_sanic(name):
    app = sanic.Sanic(name)
    app.config["LOGO"] = settings.LOGO
    app.static("main.js", "./main.js")
    return app


def make_bogo_manager():
    min_stop = settings.MINIMUM_SEQUENCE_STOP
    max_stop = settings.MAXIMUM_SEQUENCE_STOP
    sort_limit = getattr(settings, "SORT_LIMIT", 0)
    unsorted_lists = tools.unsorted_lists(min_stop, max_stop, sort_limit)

    speed_resolution = getattr(settings, "SPEED_RESOLUTION", 1)

    random_module = random.Random()
    random_module.seed(settings.RANDOM_SEED)

    dns = settings.ODBC_DNS
    schema = settings.SQL_SCHEMA_PATH
    database = db.Database(dns, schema)
    if not os.path.exists(settings.DATABASE_PATH):
        database.init()

    return bogo_manager.BogoManager(
            unsorted_lists, speed_resolution,
            database, random_module)


def make_websocket_app(sanic_app):

    class WebSocketManager:

        def __init__(self):
            self.spectators = 0

        @sanic_app.websocket("/feed")
        async def feed(self, request, ws):
            logger.info("init ws feed")
{'fraction_non_alphanumeric': 0.08687815428983417, 'fraction_numerical': 0.0021629416005767843, 'mean_word_length': 3.534313725490196, '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': '311089', 'n_tokens_mistral': 926, 'n_tokens_neox': 879, 'n_words': 198}