<commit_before># -*- coding: utf-8 -*-
"""Storj web socket module."""

import json


class Client(WebSocketClient):

    def __init__(self, pointer, file_contents):
        assert isinstance(pointer, dict)
        URI = "ws://" + pointer.get('farmer')['address'] + ":" + str(pointer.get('farmer')['port'])
        self.json = pointer
        self.file_contents = file_contents
        super(Client, self).__init__(URI)

    def opened(self):
        self.send(json.dumps(self.json))

    def closed(self, code, reason=None):
        return "Closed web socket %s %s" % (code, reason)

    def received_message(self, m):
        if m.is_binary:
            self.file_contents.write(m.data)<commit_msg>added missing import.<commit_after># -*- coding: utf-8 -*-
"""Storj web socket module."""

import json

from ws4py.client.threadedclient import WebSocketClient


class Client(WebSocketClient):

    def __init__(self, pointer, file_contents):
        assert isinstance(pointer, dict)
        URI = "ws://" + pointer.get('farmer')['address'] + ":" + str(pointer.get('farmer')['port'])
        self.json = pointer
        self.file_contents = file_contents
        super(Client, self).__init__(URI)

    def opened(self):
        self.send(json.dumps(self.json))

    def closed(self, code, reason=None):
        return "Closed web socket %s %s" % (code, reason)

    def received_message(self, m):
        if m.is_binary:
            self.file_contents.write(m.data)

{'fraction_non_alphanumeric': 0.148224043715847, 'fraction_numerical': 0.0020491803278688526, 'mean_word_length': 3.0027322404371586, 'pattern_counts': {'":': 2, '<': 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': '2535309', 'n_tokens_mistral': 461, 'n_tokens_neox': 446, 'n_words': 103}