<commit_before>#
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
# Written by <NAME>
# Copyright (c) 2015 Invenia Technical Computing Corporation
#
# License: MIT
#

"""This module exports the Julialintserver plugin class."""

import subprocess
import os
import re
import time
import socket

from SublimeLinter.lint import Linter, util, persist


def call_server(path, code, address, port, timeout=60):
    """Pass message to a juliaLint server at given address and port and return the response."""
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(timeout)
    s.connect((address, port))
    s.sendall(bytes(path, 'UTF-8'))
    s.sendall(b"\n")
    code_bytes = bytes(code, 'UTF-8')
    s.sendall(bytes(str(len(code_bytes)), 'UTF-8'))
    s.sendall(b"\n")
    s.sendall(code_bytes)
    s.sendall(b"\n")
    response = s.recv(4096).decode("utf-8")
    while response[-2:] not in ('\n\n', '\n'):
        response += s.recv(4096).decode("utf-8")
    s.close()
    return response

<commit_msg>Add comments to call_server<commit_after>#
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
# Written by <NAME>
# Copyright (c) 2015 Invenia Technical Computing Corporation
#
# License: MIT
#

"""This module exports the Julialintserver plugin class."""

import subprocess
import os
import re
import time
import socket

from SublimeLinter.lint import Linter, util, persist


def call_server(path, code, address, port, timeout=60):
    """Pass message to a juliaLint server at given address and port and return the response."""
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.settimeout(timeout)
    s.connect((address, port))
    # Send path so server can check for dependencies
    s.sendall(bytes(path, 'UTF-8'))
    s.sendall(b"\n")
    code_bytes = bytes(code, 'UTF-8')
    # Send number of bytes in code so server knows how much to receive
    s.sendall(bytes(str(len(code_bytes)), 'UTF-8'))
    s.sendall(b"\n")
    # Send the actual code
    s.sendall(code_bytes)
    s.sendall(b"\n")
    # Receive messages. Lint Server sends a empty newline when there are no more messages
    response = s.recv(4096).decode("utf-8")
    # Look at the last 2 chars; 2 newlines is an empty line or if only a single char was receive and is a newline
    while response[-2:] not in ('\n\n', '\n'):
        response += s.recv(4096).decode("utf-8")
    s.close()
    return response


{'fraction_non_alphanumeric': 0.12293430068520758, 'fraction_numerical': 0.018540910923014912, 'mean_word_length': 3.7096774193548385, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6553467', 'n_tokens_mistral': 842, 'n_tokens_neox': 805, 'n_words': 264}