<commit_before>#=======================================================================

__version__ = '''0.0.09'''
__sub_version__ = '''20090410122453'''
__copyright__ = '''(c) <NAME> 2003-2004'''


#-----------------------------------------------------------------------

import thread
import time

import event


#-----------------------------------------------------------------------

class TimerEventError(Exception):
	'''
	'''
	pass


#-----------------------------------------------------------------------
# this will set the default global timer resolution...
TIMER_RESOLUTION = 10

#---------------------------------------------------------------Timer---
class Timer(object):
	'''
	this is the base timer class.
	'''
	__callbacks__ = ()

	def __init__(self, res=None):
		'''
		'''
		self.resolution = res
		self.running = False
	def installhook(self, hook_func):
		'''
		'''
		if self.__callbacks__ == ():
			self.start()
		self.__callbacks__ += (hook_func,)
	def uninstallhook(self, hook_func):
		'''
		'''
		t = list(self.__callbacks__)
		t.remove(hook_func)
		self.__callbacks__ = tuple(t)
		##!!! check for stop...
	def start(self):
		'''
		start the timer.
		'''
		if not self.running:
			self.running = True
			return thread.start_new(self.loop, ())
		else:
			raise TypeError, 'can\'t start the timer twice'
##	def stop(self):
##		'''
##		'''
##		pass
	def loop(self, res=None):
		'''
		this is the timer loop.
		'''
		while 1:
			if res in (None, 0):
				if self.resolution in (None, 0):
					_res = TIMER_RESOLUTION
				else:
					_res = self.resolution<commit_msg>removed a stupid timer error on multiple start. now .start can be called as many times as one likes, but the timer will start only once.<commit_after>#=======================================================================

__version__ = '''0.0.09'''
__sub_version__ = '''20091009155707'''
__copyright__ = '''(c) <NAME> 2003-2004'''


#-----------------------------------------------------------------------

import thread
import time

import event


#-----------------------------------------------------------------------

class TimerEventError(Exception):
	'''
	'''
	pass


#-----------------------------------------------------------------------
# this will set the default global timer resolution...
TIMER_RESOLUTION = 10

#---------------------------------------------------------------Timer---
class Timer(object):
	'''
	this is the base timer class.
	'''
	__callbacks__ = ()

	def __init__(self, res=None):
		'''
		'''
		self.resolution = res
		self.running = False
	def installhook(self, hook_func):
		'''
		'''
		self.start()
		self.__callbacks__ += (hook_func,)
	def uninstallhook(self, hook_func):
		'''
		'''
		t = list(self.__callbacks__)
		t.remove(hook_func)
		self.__callbacks__ = tuple(t)
		##!!! check for stop...
	def start(self):
		'''
		start the timer.
		'''
		if not self.running:
			self.running = True
			return thread.start_new(self.loop, ())
##	def stop(self):
##		'''
##		'''
##		pass
	def loop(self, res=None):
		'''
		this is the timer loop.
		'''
		while 1:
			if res in (None, 0):
				if self.resolution in (None, 0):
					_res = TIMER_RESOLUTION
				else:
					_res = self.resolution
{'fraction_non_alphanumeric': 0.3422860712054966, 'fraction_numerical': 0.019362898188632106, 'mean_word_length': 1.8170624450307828, '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': '5959716', 'n_tokens_mistral': 1078, 'n_tokens_neox': 911, 'n_words': 238}