<commit_before>import time
from PythonQt import QtCore
import traceback

class TimerCallback(object):

    def __init__(self, targetFps=30):
        '''
        Construct TimerCallback.  The targetFps defines frames per second, the
        frequency for the ticks() callback method.
        '''
        self.targetFps = targetFps
        self.timer = QtCore.QTimer()
        self.timer.setSingleShot(True)

        self.singleShotTimer = QtCore.QTimer()
        self.singleShotTimer.setSingleShot(True)
        self.callback = None

    def start(self):
        '''
        Start the timer.
        '''
        self.startTime = time.time()
        self.lastTickTime = self.startTime
        self.timer.connect('timeout()', self._timerEvent)
        self.timer.start(0)

    def stop(self):
        '''
        Stop the timer.
        '''
        self.timer.stop()
        self.timer.disconnect('timeout()', self._timerEvent)

    def tick(self):
        '''
        Timer event callback method.  Subclasses can override this method.
        '''
        if self.callback:
            try:
                return self.callback()
            except:
                print traceback.format_exc()
                return False

    def singleShot(self, timeoutInSeconds):
        self.singleShotTimer.connect('timeout()', self._singleShotTimerEvent)
        self.singleShotTimer.start(int(timeoutInSeconds * 1000))

    def _singleShotTimerEvent(self):
        self.tick()<commit_msg>add TimerCallback.isActive() function<commit_after>import time
from PythonQt import QtCore
import traceback

class TimerCallback(object):

    def __init__(self, targetFps=30):
        '''
        Construct TimerCallback.  The targetFps defines frames per second, the
        frequency for the ticks() callback method.
        '''
        self.targetFps = targetFps
        self.timer = QtCore.QTimer()
        self.timer.setSingleShot(True)

        self.singleShotTimer = QtCore.QTimer()
        self.singleShotTimer.setSingleShot(True)
        self.callback = None

    def start(self):
        '''
        Start the timer.
        '''
        self.startTime = time.time()
        self.lastTickTime = self.startTime
        self.timer.connect('timeout()', self._timerEvent)
        self.timer.start(0)

    def stop(self):
        '''
        Stop the timer.
        '''
        self.timer.stop()
        self.timer.disconnect('timeout()', self._timerEvent)

    def tick(self):
        '''
        Timer event callback method.  Subclasses can override this method.
        '''
        if self.callback:
            try:
                return self.callback()
            except:
                print traceback.format_exc()
                return False

    def isActive(self):
        '''
        Return whether or not the timer is active.
        '''
        return self.timer.isActive()

    def singleShot(self, timeoutInSeconds):
        self.singleShotTimer.connect('timeout()', self._singleShotTimerEvent)
        self.singleShotTimer.start(int(timeoutInSeconds * 1000))

    def _singleShotTimerEvent(self):
        self.tick()
{'fraction_non_alphanumeric': 0.10041706769329484, 'fraction_numerical': 0.004491498235482836, 'mean_word_length': 2.06286836935167, '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': '5811254', 'n_tokens_mistral': 879, 'n_tokens_neox': 838, 'n_words': 191}