<commit_before>#!/usr/bin/env python3
import logging

from binascii import unhexlify
from struct import unpack

log = logging.getLogger("protocol_helpers")


def crc8(byteData):
    """
    Generate 8 bit CRC of supplied string
    """
    CRC = 0
    # for j in range(0, len(str),2):
    for b in byteData:
        # char = int(str[j:j+2], 16)
        # print(b)
        CRC = CRC + b
        CRC &= 0xFF
    return CRC


def get_resp_defn(key, defns):
    """
    look for a definition for the supplied key
    """
    # print(key, defns)
    if not key:
        return None
    key = key.decode("utf-8")<commit_msg>Update protocol_helpers.py<commit_after>#!/usr/bin/env python3
import logging

from binascii import unhexlify
from struct import unpack

log = logging.getLogger("protocol_helpers")


def crc8(byteData):
    """
    Generate 8 bit CRC of supplied string
    """
    CRC = 0
    # for j in range(0, len(str),2):
    for b in byteData:
        # char = int(str[j:j+2], 16)
        # print(b)
        CRC = CRC + b
        CRC &= 0xFF
    return CRC


def get_resp_defn(key, defns):
    """
    look for a definition for the supplied key
    """
    # print(key, defns)
    if not key:
        return None
    try:
        key = key.decode("utf-8")
    except UnicodeDecodeError as e:
        log.info(f"get_resp_defn: key decode error for {key}")
{'fraction_non_alphanumeric': 0.112417340191036, 'fraction_numerical': 0.016164584864070537, 'mean_word_length': 2.396508728179551, 'pattern_counts': {'":': 0, '<': 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': '2963075', 'n_tokens_mistral': 474, 'n_tokens_neox': 456, 'n_words': 141}