<commit_before>import re
import subprocess
import socket
import sys
from time import sleep
from threading import Thread

from utils.project import get_project_file


class Idetools:
    # Fields
    service = None
    running = False
    outThread = None

    pattern = re.compile(
        '^(?P<cmd>\S+)\s(?P<ast>\S+)\s' +
        '(?P<symbol>\S+)( (?P<instance>\S+))?\s' +
        '(?P<type>[^\t]+)\s(?P<path>[^\t]+)\s' +
        '(?P<line>\d+)\s(?P<col>\d+)\s' +
        '(?P<description>\".+\")?')

    # Methods
    @staticmethod
    def print_output(out):
        for line in iter(out.readline, b''):
            print(line.rstrip())

    @staticmethod
    def linesplit(socket):
        buffer = None

        if sys.version_info < (3, 0):
            buffer = socket.recv(4096)
        else:
            buffer = socket.recv(4096).decode('UTF-8')

        buffering = True
        while buffering:
            if "\n" in buffer:
                (line, buffer) = buffer.split("\n", 1)
                yield line + "\n"
            else:
                more = socket.recv(4096)
                if not more:
                    buffering = False
                else:
                    buffer += more.decode('UTF-8')
        if buffer:
            yield buffer

    @staticmethod
    def opensock():
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        s.connect(("localhost", 8088))
        return s

    @staticmethod
    def sendrecv(args, getresp=True):
        sock = None
        try:
            sock = Idetools.opensock()

            if sys.version_info < (3, 0):
                sock.send(args + "\r\n")<commit_msg>Switched socket connection initialization<commit_after>import re
import subprocess
import socket
import sys
from time import sleep
from threading import Thread

from utils.project import get_project_file


class Idetools:
    # Fields
    service = None
    running = False
    outThread = None

    pattern = re.compile(
        '^(?P<cmd>\S+)\s(?P<ast>\S+)\s' +
        '(?P<symbol>\S+)( (?P<instance>\S+))?\s' +
        '(?P<type>[^\t]+)\s(?P<path>[^\t]+)\s' +
        '(?P<line>\d+)\s(?P<col>\d+)\s' +
        '(?P<description>\".+\")?')

    # Methods
    @staticmethod
    def print_output(out):
        for line in iter(out.readline, b''):
            print(line.rstrip())

    @staticmethod
    def linesplit(socket):
        buffer = None

        if sys.version_info < (3, 0):
            buffer = socket.recv(4096)
        else:
            buffer = socket.recv(4096).decode('UTF-8')

        buffering = True
        while buffering:
            if "\n" in buffer:
                (line, buffer) = buffer.split("\n", 1)
                yield line + "\n"
            else:
                more = socket.recv(4096)
                if not more:
                    buffering = False
                else:
                    buffer += more.decode('UTF-8')
        if buffer:
            yield buffer

    @staticmethod
    def opensock():
        return socket.create_connection(("localhost", 8088), 3)

    @staticmethod
    def sendrecv(args, getresp=True):
        sock = None
        try:
            sock = Idetools.opensock()

            if sys.version_info < (3, 0):
                sock.send(args + "\r\n")
{'fraction_non_alphanumeric': 0.14355528405620036, 'fraction_numerical': 0.014355528405620037, 'mean_word_length': 1.6910435497124077, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, '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': '4508117', 'n_tokens_mistral': 1077, 'n_tokens_neox': 992, 'n_words': 231}