<commit_before>"""
TODO documentation
"""


from ProbPy import RandVar


class EventEle:
    def __init__(self, var, val):
        if type(var) is not RandVar or val is None:
            raise Exception

        self.var = var
        self.val = val


class Event:
    def __init__(self, tlist=None, var=None, val=None):
        if tlist is not None and type(tlist) is list:
            self.event = [EventEle(i[0], i[1]) for i in tlist]
        elif var is not None or val is not None:
            self.event = [EventEle(var, val)]
        else:
            self.event = []

    def varInEvent(self, var):
        for i in self.event:
            if i.var.name == var.name:
                return True

        return False

    def value(self, var):
        for i in self.event:
            if i.var.name == var.name:
                return i.val

        return None

    def setValue(self, var, val):
        for i in range(len(self.event)):
            if self.event[i].var.name == var.name:
                self.event[i].val = val
                return

        self.event.append(EventEle(var, val))

    def __iter__(self):
        cindex = 0
        while cindex < len(self.event):
            ele = self.event[cindex]
            yield (ele.var, ele.val)
            cindex += 1<commit_msg>Implemented exception for Eventele class<commit_after>"""
TODO documentation
"""


from ProbPy import RandVar


class EventEle:
    def __init__(self, var, val):
        if type(var) is not RandVar:
            raise EventEleEx("var")
        elif val is None:
            raise EventEleEx("val")

        self.var = var
        self.val = val


class Event:
    def __init__(self, tlist=None, var=None, val=None):
        if tlist is not None and type(tlist) is list:
            self.event = [EventEle(i[0], i[1]) for i in tlist]
        elif var is not None or val is not None:
            self.event = [EventEle(var, val)]
        else:
            self.event = []

    def varInEvent(self, var):
        for i in self.event:
            if i.var.name == var.name:
                return True

        return False

    def value(self, var):
        for i in self.event:
            if i.var.name == var.name:
                return i.val

        return None

    def setValue(self, var, val):
        for i in range(len(self.event)):
            if self.event[i].var.name == var.name:
                self.event[i].val = val
                return

        self.event.append(EventEle(var, val))

    def __iter__(self):
        cindex = 0
        while cindex < len(self.event):
            ele = self.event[cindex]
            yield (ele.var, ele.val)
            cindex += 1


class EventEleEx(Exception):
    def __init__(self, op):
        if op is "var":
            self.txt = "Bad value for var argument of Event element."
        elif op is "val":
            self.txt = "Bad value for val argument of Event element."

    def __str__(self):
        return self.txt
{'fraction_non_alphanumeric': 0.10339039946290701, 'fraction_numerical': 0.002685464921114468, 'mean_word_length': 1.6465364120781527, 'pattern_counts': {'":': 2, '<': 5, '<?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': '2432525', 'n_tokens_mistral': 930, 'n_tokens_neox': 880, 'n_words': 288}