<commit_before>import os
import uuid

from collections import defaultdict
from tornado import ioloop, web, websocket, escape

# We don't need to override `data_received`
# pylint: disable=W0223
class ChatClient(websocket.WebSocketHandler):

    CHANNELS = defaultdict(set)

    nick = None
    channel_id = None

    def __init__(self, *args, **kwargs):
        super(ChatClient, self).__init__(*args, **kwargs)

    def check_origin(self, origin):
        return True

    @property
    def channel(self):
        return self.CHANNELS[self.channel_id]

    def broadcast(self, message_type, content=None, tell_me=False):
        '''
        Broadcast a message. Optionally, to myself as well.
        '''

        clients = self.channel
        if not tell_me:
            clients = clients - {self}

        for client in clients:
            client.write_message({
                "nick": self.nick,
                "type": message_type,
                "message": content
            })

    # Open allows for any number arguments, unlike what pylint thinks.
    # pylint: disable=W0221
    def open(self, channel_id):
        self.nick = str(uuid.uuid4())
        self.channel_id = channel_id
        self.channel.add(self)
        self.broadcast("join")

    def on_message(self, message):
        self.broadcast("chat", message)

    def on_close(self):
        self.channel.remove(self)
        if not self.channel:
            del self.CHANNELS[self.channel_id]
        self.broadcast("part")

def main():
    application = web.Application([
        (r"/([^/]+)", ChatClient),
    ], debug=True)
<commit_msg>Forward static requests to compiled ember-cli app<commit_after># pylint: disable=W0223

import os
import uuid

from collections import defaultdict
from tornado import ioloop, web, websocket, escape

class MainHandler(web.RequestHandler):
    def get(self):
        self.render("dist/index.html")

class ChatClient(websocket.WebSocketHandler):

    CHANNELS = defaultdict(set)

    nick = None
    channel_id = None

    def __init__(self, *args, **kwargs):
        super(ChatClient, self).__init__(*args, **kwargs)

    def check_origin(self, origin):
        return True

    @property
    def channel(self):
        return self.CHANNELS[self.channel_id]

    def broadcast(self, message_type, content=None, tell_me=False):
        '''
        Broadcast a message. Optionally, to myself as well.
        '''

        clients = self.channel
        if not tell_me:
            clients = clients - {self}

        for client in clients:
            client.write_message({
                "nick": self.nick,
                "type": message_type,
                "message": content
            })

    # Open allows for any number arguments, unlike what pylint thinks.
    # pylint: disable=W0221
    def open(self, channel_id):
        self.nick = str(uuid.uuid4())
        self.channel_id = channel_id
        self.channel.add(self)
        self.broadcast("join")

    def on_message(self, message):
        self.broadcast("chat", message)

    def on_close(self):
        self.channel.remove(self)
        if not self.channel:
            del self.CHANNELS[self.channel_id]
        self.broadcast("part")

def main():
    application = web.Application([
        (r"/", MainHandler),
        (r'/assets/(.*)', web.StaticFileHandler, {'path': 'dist/assets'}),
        (r"/c/([^/]+)", ChatClient),
    ], debug=True)

{'fraction_non_alphanumeric': 0.11396094433109881, 'fraction_numerical': 0.0052462838822500725, 'mean_word_length': 2.3879565646594276, 'pattern_counts': {'":': 6, '<': 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': '3641266', 'n_tokens_mistral': 1038, 'n_tokens_neox': 988, 'n_words': 256}