<commit_before>import ClockObject
import Task

class Timer:

    def __init__(self):
        """ __init__()
        """
        self.clock = ClockObject.ClockObject.getGlobalClock()
        self.finalT = 0.0
        self.currT = 0.0
        self.name = 'default-timer'
        self.started = 0

    def start(self, t, name):
        """ start(t, name)
        """
        if (self.started):
            self.stop()
        self.finalT = t
        self.name = name
        self.startT = self.clock.getFrameTime()
        self.currT = 0.0
        taskMgr.spawnMethodNamed(self.__timerTask, self.name + '-run')
        self.started = 1

    def stop(self):
        """ stop()
        """
        if (not self.started):
            return 0.0
        taskMgr.removeTasksNamed(self.name + '-run')
        self.started = 0
        return self.currT

    def resume(self):
        """ resume()
        """
        assert(self.currT <= self.finalT)
        assert(self.started == 0)
        self.start(self.finalT - self.currT, self.name)

    def restart(self):
        """ restart()
        """
        self.start(self.finalT, self.name)

    def isStarted(self):
        """ isStarted()
        """
        return self.started

    def addT(self, t):
        """ addT(t)
        """
        self.finalT = self.finalT + t

    def setT(self, t):
        """ setT(t)
        """
        self.finalT = t

    def getT(self):
        """ getT()
        """
        return (self.finalT - self.currT)

    def __timerTask(self, task):
        t = self.clock.getFrameTime()
        te = t - self.startT 
        self.currT = te
        if (te >= self.finalT):
            messenger.send(self.name)
            return Task.done
        return Task.cont
<commit_msg>*** empty log message ***<commit_after>import ClockObject
import Task

class Timer:

    def __init__(self):
        """ __init__()
        """
        self.clock = ClockObject.ClockObject.getGlobalClock()
        self.finalT = 0.0
        self.currT = 0.0
        self.name = 'default-timer'
        self.started = 0
        self.callback = None

    def start(self, t, name):
        """ start(t, name)
        """
        if (self.started):
            self.stop()
        self.callback = None
        self.finalT = t
        self.name = name
        self.startT = self.clock.getFrameTime()
        self.currT = 0.0
        taskMgr.spawnMethodNamed(self.__timerTask, self.name + '-run')
        self.started = 1

    def startCallback(self, t, callback):
        """ startCallback(t, callback)
        """
        if (self.started):
            self.stop()
        self.callback = callback 
        self.finalT = t
        self.name = 'default-timer'
        self.startT = self.clock.getFrameTime()
        self.currT = 0.0
        taskMgr.spawnMethodNamed(self.__timerTask, self.name + '-run')
        self.started = 1

    def stop(self):
        """ stop()
        """
        if (not self.started):
            return 0.0
        taskMgr.removeTasksNamed(self.name + '-run')
        self.started = 0
        return self.currT

    def resume(self):
        """ resume()
        """
        assert(self.currT <= self.finalT)
        assert(self.started == 0)
        self.start(self.finalT - self.currT, self.name)

    def restart(self):
        """ restart()
        """
        self.start(self.finalT, self.name)

    def isStarted(self):
        """ isStarted()
        """
        return self.started

    def addT(self, t):
        """ addT(t)
        """
        self.finalT = self.finalT + t

    def setT(self, t):
        """ setT(t)
        """
        self.finalT = t

    def getT(self):
        """ getT()
        """
        return (self.finalT - self.currT)

    def __timerTask(self, task):
        t = self.clock.getFrameTime()
        te = t - self.startT 
        self.currT = te
        if (te >= self.finalT):
            if (self.callback != None):
                self.callback()
            else:
                messenger.send(self.name)
            return Task.done
        return Task.cont

{'fraction_non_alphanumeric': 0.13420019627085378, 'fraction_numerical': 0.00662414131501472, 'mean_word_length': 1.5354477611940298, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6780576', 'n_tokens_mistral': 1306, 'n_tokens_neox': 1244, 'n_words': 261}