<commit_before>from hwt.pyUtils.arrayQuery import flatten
from hwt.synthesizer.interface import Interface
from hwtSimApi.agents.base import AgentBase
from hwtSimApi.hdlSimulator import HdlSimulator
from ipCorePackager.constants import DIRECTION, INTF_DIRECTION


class UniversalCompositeAgent(AgentBase):
    """
    Composite agent with agent for addr and data channel
    enable is shared
    """

    def getEnable(self):
        return self.__enable

    def setEnable(self, v):
        """
        Distribute change of enable on child agents
        """
        self.__enable = v
        for o in self.intf._interfaces:
            o._ag.setEnable(v)

    def __init__(self, sim: HdlSimulator, intf: Interface):
        self.__enable = True
        super(UniversalCompositeAgent, self).__init__(sim, intf)
        for i in intf._interfaces:
            i._initSimAgent(sim)

    def getDrivers(self):
        return list(flatten(
            (i._ag.getMonitors() if i._direction == INTF_DIRECTION.MASTER else i._ag.getDrivers()
            for i in self.intf._interfaces),
            level=1
        ))

    def getMonitors(self):
        return list(flatten(
            (i._ag.getMonitors() if i._direction == INTF_DIRECTION.MASTER else i._ag.getDrivers()
            for i in self.intf._interfaces),
            level=1
        ))
<commit_msg>codestyle<commit_after>from hwt.pyUtils.arrayQuery import flatten
from hwt.synthesizer.interface import Interface
from hwtSimApi.agents.base import AgentBase
from hwtSimApi.hdlSimulator import HdlSimulator
from ipCorePackager.constants import INTF_DIRECTION


class UniversalCompositeAgent(AgentBase):
    """
    Composite agent with agent for addr and data channel
    enable is shared
    """

    def getEnable(self):
        return self.__enable

    def setEnable(self, v):
        """
        Distribute change of enable on child agents
        """
        self.__enable = v
        for o in self.intf._interfaces:
            o._ag.setEnable(v)

    def __init__(self, sim: HdlSimulator, intf: Interface):
        self.__enable = True
        super(UniversalCompositeAgent, self).__init__(sim, intf)
        for i in intf._interfaces:
            i._initSimAgent(sim)

    def getDrivers(self):
        return list(flatten(
            (i._ag.getMonitors() if i._direction == INTF_DIRECTION.MASTER else i._ag.getDrivers()
            for i in self.intf._interfaces),
            level=1
        ))

    def getMonitors(self):
        return list(flatten(
            (i._ag.getMonitors() if i._direction == INTF_DIRECTION.MASTER else i._ag.getDrivers()
            for i in self.intf._interfaces),
            level=1
        ))

{'fraction_non_alphanumeric': 0.08516177017478617, 'fraction_numerical': 0.0014875418371141688, 'mean_word_length': 2.4575835475578405, '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': '3389742', 'n_tokens_mistral': 820, 'n_tokens_neox': 787, 'n_words': 203}