<commit_before>import logging
from time import time

class DelayItem:
    def __init__(self, _id, source, delay, target, logger=None):
        self.id = _id
        self.sourceEvent = source
        self.delay = delay
        self.targetEvent = target
        self.timer = 0
        self.logger = logger
        if not self.logger:
            self.logger = logging.getLogger(__name__)
            self.logger.setLevel(logging.INFO)

    def setup(self):
        self.sourceEvent += self.trigger

    def destroy(self):
        self.sourceEvent -= self.trigger

    def trigger(self):
        self.timer = self.delay
        self.logger.debug('DelayItem with ID `{0}` triggered by source event')

    def update(self, dt=None):
        if self.timer <= 0:
            return # we're not running

        self.timer -= dt # count down

        if self.timer <= 0:
            # trigger target event
            self.targetEvent()
            self.logger.debug('DelayItem with ID `{0}` triggered target event')

class DelayEvents:
    def __init__(self, options = {}):
        self.options = options
        self.dynamic_events = None
        self.logger = logging.getLogger(__name__)
        self.logger.setLevel(logging.DEBUG if 'verbose' in options and options['verbose'] else logging.INFO)
        self._delay_items = []
        self._last_update = None

    def __del__(self):
        self.destroy()

    def setup(self, dynamic_events):
        self.dynamic_events = dynamic_events
        self._delay_items = self._options_to_delay_items()

        for delay_item in self._delay_items:
            delay_item.setup()

        self._last_update = time()

    def destroy(self):
        for delay_item in self._delay_items:
            delay_item.destroy()

        self._delay_items = []
        self.dynamic_events = None

    def update(self, dt=None):
        if not dt:
            t = time()
            dt = t - self._last_update
            self._last_update = t

        for delay_item in self._delay_items:
            delay_item.update(dt)

    def _options_to_delay_items(self):
        delay_items = []

        for _id, params in self.options.items():<commit_msg>Patch in DelayEvents component to only consider config items as delay item config if the value is iterable<commit_after>import logging
from time import time

class DelayItem:
    def __init__(self, _id, source, delay, target, logger=None):
        self.id = _id
        self.sourceEvent = source
        self.delay = delay
        self.targetEvent = target
        self.timer = 0
        self.logger = logger
        if not self.logger:
            self.logger = logging.getLogger(__name__)
            self.logger.setLevel(logging.INFO)

    def setup(self):
        self.sourceEvent += self.trigger

    def destroy(self):
        self.sourceEvent -= self.trigger

    def trigger(self):
        self.timer = self.delay
        self.logger.debug('DelayItem with ID `{0}` triggered by source event')

    def update(self, dt=None):
        if self.timer <= 0:
            return # we're not running

        self.timer -= dt # count down

        if self.timer <= 0:
            # trigger target event
            self.targetEvent()
            self.logger.debug('DelayItem with ID `{0}` triggered target event')

class DelayEvents:
    def __init__(self, options = {}):
        self.options = options
        self.dynamic_events = None
        self.logger = logging.getLogger(__name__)
        self.logger.setLevel(logging.DEBUG if 'verbose' in options and options['verbose'] else logging.INFO)
        self._delay_items = []
        self._last_update = None

    def __del__(self):
        self.destroy()

    def setup(self, dynamic_events):
        self.dynamic_events = dynamic_events
        self._delay_items = self._options_to_delay_items()

        for delay_item in self._delay_items:
            delay_item.setup()

        self._last_update = time()

    def destroy(self):
        for delay_item in self._delay_items:
            delay_item.destroy()

        self._delay_items = []
        self.dynamic_events = None

    def update(self, dt=None):
        if not dt:
            t = time()
            dt = t - self._last_update
            self._last_update = t

        for delay_item in self._delay_items:
            delay_item.update(dt)

    def _options_to_delay_items(self):
        delay_items = []

        for _id, params in self.options.items():
            if not hasattr(params, '__iter__'):
                continue

{'fraction_non_alphanumeric': 0.09233487961122155, 'fraction_numerical': 0.002208968411751712, 'mean_word_length': 2.0760869565217392, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4532054', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1240, 'n_words': 335}