<commit_before>from time import time
from inspect import isclass
import pineal.livecoding


class Visuals(dict):
    def new(self, name):
        v = Visual(self, name)
        self[name] = v
        return v


class Visual():
    def __init__(self, visuals, name):
        self.visuals = visuals
        print 'creating visual'
        self.name = name
        self._stack = list()
        self.box = Box()
        self.osc = {}
        self.lastTime = time()

    def load(self, code):
        self._stack.append(code)

    def remove(self):
        del self.visuals[self.name]

    def update(self):
        if not self._stack:
            return

        try:
            variables = self.box.__dict__.copy()
            exec(self._stack[-1], self.box.__dict__)
            for k,v in variables.items():
                if (
                    not callable(v) and not isclass(v)
                ) and k in self.box.__dict__.keys():
                    self.box.__dict__[k] = v
            self.loop()
        except Exception as e:
            print self.error_log(e)

            self._stack = self._stack[:-1]
            if not self._stack:
                print "%s.py is BROKEN" % self.name
            else:
                self.update() # WARNING recursion!

    def get_var(self):
        d = self.box.__dict__
        return [k for k in d.keys() if isinstance(d[k], float)]

    def set_var(self, var, value):
        self.osc[var] = value

    def error_log(self, e):
        log = self.name + '.py'
        log += str(e)

        if hasattr(e, 'text'):
            log += "\n"+str(e.text)

        return log

    def loop(self):
        for k in self.get_var():
            if k not in self.osc.keys():
                self.osc[k] = self.box.__dict__[k]

        for k in self.osc.keys():
            if k in self.get_var():
                # if osc[] is changed:
                self.box.__dict__[k] = self.osc[k]
                # elif values are changed:
                #   update osc[] with new values
            else:
                del self.osc[k]

        pineal.livecoding.__dict__['dt'] = time() - self.lastTime
        self.lastTime = time()
<commit_msg>dt is no more in OSC vars<commit_after>from time import time
from inspect import isclass
import pineal.livecoding


class Visuals(dict):
    def new(self, name):
        v = Visual(self, name)
        self[name] = v
        return v


class Visual():
    def __init__(self, visuals, name):
        self.visuals = visuals
        print 'creating visual'
        self.name = name
        self._stack = list()
        self.box = Box()
        self.osc = {}
        self.lastTime = time()

    def load(self, code):
        self._stack.append(code)

    def remove(self):
        del self.visuals[self.name]

    def update(self):
        if not self._stack:
            return

        try:
            variables = self.box.__dict__.copy()
            exec(self._stack[-1], self.box.__dict__)
            for k,v in variables.items():
                if (
                    not callable(v) and not isclass(v)
                ) and k in self.box.__dict__.keys():
                    self.box.__dict__[k] = v
            self.loop()
        except Exception as e:
            print self.error_log(e)

            self._stack = self._stack[:-1]
            if not self._stack:
                print "%s.py is BROKEN" % self.name
            else:
                self.update() # WARNING recursion!

    def get_var(self):
        d = self.box.__dict__
        return [k for k in d.keys() if isinstance(d[k], float) and k!='dt']

    def set_var(self, var, value):
        self.osc[var] = value

    def error_log(self, e):
        log = self.name + '.py'
        log += str(e)

        if hasattr(e, 'text'):
            log += "\n"+str(e.text)

        return log

    def loop(self):
        for k in self.get_var():
            if k not in self.osc.keys():
                self.osc[k] = self.box.__dict__[k]

        for k in self.osc.keys():
            if k in self.get_var():
                # if osc[] is changed:
                self.box.__dict__[k] = self.osc[k]
                # elif values are changed:
                #   update osc[] with new values
            else:
                del self.osc[k]

        pineal.livecoding.__dict__['dt'] = time() - self.lastTime
        self.lastTime = time()

{'fraction_non_alphanumeric': 0.11612021857923498, 'fraction_numerical': 0.0009107468123861566, 'mean_word_length': 1.4693648116919618, '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': '317985', 'n_tokens_mistral': 1352, 'n_tokens_neox': 1295, 'n_words': 360}