<commit_before>from psistats.libsensors.lib.sensors import init
from psistats.libsensors.lib.sensors import iter_detected_chips
from psistats.libsensors.lib.sensors import cleanup
from psistats.libsensors.lib.sensors import SENSORS_FEATURE_FAN
from psistats.libsensors.lib.sensors import SENSORS_FEATURE_TEMP
from psistats.libsensors.lib.sensors import SensorsError

__all__ = ['Sensors', 'CantReadSensor']

class CantReadSensor(Exception):
    """Thrown when a sensor can not be read"""
    def __init__(self, *args, **kwargs):
        Exception.__init__(self, *args, **kwargs)


class Sensors():
    
    def __init__(self):
        self.chips = {}
        self.initted = False

    def init(self):
        """Initialize sensors"""
        init()
        self.initted = True

    def cleanup(self):
        """Cleanup after using sensors"""
        cleanup()
        self.initted = False
    
    def add_chip(self, chipName):
        """Add a chip"""
        for chip in iter_detected_chips(chip_name=chipName):
            self.chips[chipName] = {}

            for feature in chip:
                self.chips[chipName][feature.label] = feature

    def _get_unit(self, feature):
        if feature.type == SENSORS_FEATURE_FAN:<commit_msg>Code cleanup<commit_after>from psistats.libsensors.lib.sensors import init
from psistats.libsensors.lib.sensors import iter_detected_chips
from psistats.libsensors.lib.sensors import cleanup
from psistats.libsensors.lib.sensors import SENSORS_FEATURE_FAN
from psistats.libsensors.lib.sensors import SENSORS_FEATURE_TEMP
from psistats.libsensors.lib.sensors import SensorsError

__all__ = ['Sensors', 'CantReadSensor']

class CantReadSensor(Exception):
    """Thrown when a sensor can not be read"""
    def __init__(self, *args, **kwargs):
        Exception.__init__(self, *args, **kwargs)


class Sensors(object):
    """Simple abstraction over libsensors""" 
    def __init__(self):
        self.chips = {}
        self.initted = False

    def init(self):
        """Initialize sensors"""
        init()
        self.initted = True

    def cleanup(self):
        """Cleanup after using sensors"""
        cleanup()
        self.initted = False
    
    def add_chip(self, chipName):
        """Add a chip"""
        for chip in iter_detected_chips(chip_name=chipName):
            self.chips[chipName] = {}

            for feature in chip:
                self.chips[chipName][feature.label] = feature

    def _get_unit(self, feature):
        if feature.type == SENSORS_FEATURE_FAN:
{'fraction_non_alphanumeric': 0.10347551342812006, 'fraction_numerical': 0.0, 'mean_word_length': 3.072347266881029, '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': '7225629', 'n_tokens_mistral': 785, 'n_tokens_neox': 758, 'n_words': 184}