<commit_before>import sched, time, datetime, threading

class Scheduler:
    def __init__(self, timef = time.time, delayf = time.sleep):
        self.__sched_obj = sched.scheduler(timef, delayf)

    def show(self):
        print('*' * 20)
        print('Total Event Number: %d\n' %len(self.__sched_obj.queue))
        for index, item in enumerate(self.__sched_obj.queue):
            print('Event %d' %index, item)
        print('*' * 20)

    # @instance: would be date or delta timesec
    # @argv: would be tuple as a pointer. It's quite similar with pthead_create
    def regist(self, instance, act, argv, prio = 0):
        if type(instance) == datetime.datetime:
            self.__sched_obj.enterabs(instance.timestamp(), prio, act, argv)
        else: # include type of time.time
        # Prototype: sched.enter(timesec, prio, act, *argv, **kwarg)
            self.__sched_obj.enter(instance, prio, act, argv)

    def cancel(self, event_index):
        self.__sched_obj.cancel(self.__sched_obj.queue[event_index])

    def run(self, blocking = True):
        self.__sched_obj.run(blocking)
<commit_msg>sched: Seperate declarations and initializations<commit_after>import sched, time, datetime, threading

class Scheduler:
    def __init__(self, timef = time.time, delayf = time.sleep):
        # Declaration
        self.__sched_obj = None
        
        # Initialization
        self.__sched_obj = sched.scheduler(timef, delayf)

    def show(self):
        print('*' * 20)
        print('Total Event Number: %d\n' %len(self.__sched_obj.queue))
        for index, item in enumerate(self.__sched_obj.queue):
            print('Event %d' %index, item)
        print('*' * 20)

    # @instance: would be date or delta timesec
    # @argv: would be tuple as a pointer. It's quite similar with pthead_create
    def regist(self, instance, act, argv, prio = 0):
        if type(instance) == datetime.datetime:
            self.__sched_obj.enterabs(instance.timestamp(), prio, act, argv)
        else: # include type of time.time
        # Prototype: sched.enter(timesec, prio, act, *argv, **kwarg)
            self.__sched_obj.enter(instance, prio, act, argv)

    def cancel(self, event_index):
        self.__sched_obj.cancel(self.__sched_obj.queue[event_index])

    def run(self, blocking = True):
        self.__sched_obj.run(blocking)

{'fraction_non_alphanumeric': 0.11877394636015326, 'fraction_numerical': 0.004257130693912303, 'mean_word_length': 2.903654485049834, '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': '4190048', 'n_tokens_mistral': 743, 'n_tokens_neox': 711, 'n_words': 194}