<commit_before>from collections import defaultdict
import struct

import serial
from serial import SerialException

PORT="COM4"

def listen(s):
    keys = ['Time left', 'T1', 'T2', 'Off goal', 'Temp diff', 'Part', 'State', 'Cycle']
    print("\t".join(keys))
    while True:
        try:
            row = defaultdict(str)
            message = s.read(30)
            parse_message(message, row)
            if row:
                print("\t".join(map(lambda key: str(row[key]), keys)))
        except SerialException as e:
            pass
        except KeyboardInterrupt:
            break


def parse_message(message, data):
    while len(message) > 4 and message[0:4] != b"MSG:":
        message = message[1:]
    if len(message) == 0:
        return False
    message = message[4:]
    while len(message) > 0:
        try:
            if message[0] == b'T'[0]:<commit_msg>Fixed merge errors.<commit_after>from collections import defaultdict
import struct

import serial
from serial import SerialException

PORT="COM4"

def listen(s):
    keys = ['Time left', 'T1', 'T2', 'Off goal', 'Temp diff', 'Part', 'State', 'Cycle']
    print("\t".join(keys))
    while True:
        try:
            message = s.read(100)
            if len(message) == 0:
                continue
            if message[0:4] != b"MSG:":
                try:
                    print(message.decode('ascii'))
                    sleep(0.2)
                except UnicodeDecodeError:
                    pass
            else:
                row = defaultdict(str)
                parse_message(message, row)
                if row:
                    print("\t".join(map(lambda key: str(row[key]), keys)))        except SerialException as e:
            pass
        except KeyboardInterrupt:
            break


def parse_message(message, data):
    while len(message) > 4 and message[0:4] != b"MSG:":
        message = message[1:]
    if len(message) == 0:
        return False
    message = message[4:]
    while len(message) > 0:
        try:
            if message[0] == b'T'[0]:
{'fraction_non_alphanumeric': 0.12681510164569215, 'fraction_numerical': 0.016456921587608905, 'mean_word_length': 1.8589211618257262, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 7, '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': '2307176', 'n_tokens_mistral': 619, 'n_tokens_neox': 589, 'n_words': 167}