<commit_before>from collections import defaultdict, namedtuple

import logging
import time

try:
    from ipywidgets import interact
except ImportError:
    def interact(*args, **kwargs):
        msg = 'You first have to install ipywidgets to use the control widgets.'
        logging.getLogger(__name__).warning(msg)
        return None


Event = namedtuple('Event', ('name', 'old_value', 'new_value'))


class Module(object):
    possible_events = set()

    def __init__(self,
                 type, id, alias,
                 robot):
        self.id = id
        self.type = type
        self.alias = alias
        self._delegate = robot
        self._value = None
        self._cb = defaultdict(list)
        self._led = True
        self._L0_temperature = None
        self._L0_voltage = None
        self._firmware_revision = "Unknown"

    def __repr__(self):
        return ('<{self.type} '
                'alias="{self.alias}" '
                'id={self.id} '
                '{state}>'.format(self=self,
                                  state=self._state_repr()))

    def _state_repr(self):
        return ('state={}'.format(self._value)
                if self._value is not None else
                '')

    def _update(self, new_state):
        if 'L0_temperature' in new_state:
            self._L0_temperature = new_state['L0_temperature']
        if 'L0_voltage' in new_state:
            self._L0_voltage = new_state['L0_voltage']
        if 'revision' in new_state:
            self._firmware_revision = new_state['revision']

    def _push_value(self, key, new_val):
        self._delegate.update_cmd(self.alias, key, new_val)

    @property
    def L0_temperature(self):
        self._push_value('L0_temperature', "")
        time.sleep(0.1)
        return self._L0_temperature

    @property
    def L0_voltage(self):
        self._push_value('L0_voltage', "")
        time.sleep(0.1)
        return self._L0_voltage

    @property
    def firmware_revision(self):
        self._push_value('revision', "")
        time.sleep(0.1)
        return self._firmware_revision

    @property
    def led(self):
        return self._led<commit_msg>Add more time for ask reply informations<commit_after>from collections import defaultdict, namedtuple

import logging
import time

try:
    from ipywidgets import interact
except ImportError:
    def interact(*args, **kwargs):
        msg = 'You first have to install ipywidgets to use the control widgets.'
        logging.getLogger(__name__).warning(msg)
        return None


Event = namedtuple('Event', ('name', 'old_value', 'new_value'))


class Module(object):
    possible_events = set()

    def __init__(self,
                 type, id, alias,
                 robot):
        self.id = id
        self.type = type
        self.alias = alias
        self._delegate = robot
        self._value = None
        self._cb = defaultdict(list)
        self._led = True
        self._L0_temperature = None
        self._L0_voltage = None
        self._firmware_revision = "Unknown"

    def __repr__(self):
        return ('<{self.type} '
                'alias="{self.alias}" '
                'id={self.id} '
                '{state}>'.format(self=self,
                                  state=self._state_repr()))

    def _state_repr(self):
        return ('state={}'.format(self._value)
                if self._value is not None else
                '')

    def _update(self, new_state):
        if 'L0_temperature' in new_state:
            self._L0_temperature = new_state['L0_temperature']
        if 'L0_voltage' in new_state:
            self._L0_voltage = new_state['L0_voltage']
        if 'revision' in new_state:
            self._firmware_revision = new_state['revision']

    def _push_value(self, key, new_val):
        self._delegate.update_cmd(self.alias, key, new_val)

    @property
    def L0_temperature(self):
        self._push_value('L0_temperature', "")
        time.sleep(0.3)
        return self._L0_temperature

    @property
    def L0_voltage(self):
        self._push_value('L0_voltage', "")
        time.sleep(0.3)
        return self._L0_voltage

    @property
    def firmware_revision(self):
        self._push_value('revision', "")
        time.sleep(0.3)
        return self._firmware_revision

    @property
    def led(self):
        return self._led
{'fraction_non_alphanumeric': 0.10593900481540931, 'fraction_numerical': 0.009172208209126348, 'mean_word_length': 2.1090520313613683, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2453543', 'n_tokens_mistral': 1346, 'n_tokens_neox': 1275, 'n_words': 287}