<commit_before>import graphics
import time
import datetime
import game

class Countdown(game.Game):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.timer = graphics.Rectangle(112, 7, x=0, y=8)
        self.text = graphics.TextSprite("1:00:00.000 REMAIN", x=0, y=0, width=5, height=7)
        self.end_time = datetime.datetime(2015, 4, 12, 10, 0, 0)
        #self.end_time = datetime.datetime(2015, 4, 12, 9, 53, 0)

        self.sprites.add(self.timer)
        self.sprites.add(self.text)

        self.framerate = 100
        self.light = False
        self.blink = False

    def loop(self):
        tdiff = self.end_time - datetime.datetime.now()

        if not self.light and tdiff.seconds <= 900:
            self.light = True
            self.trigger("alert", "on")

        if tdiff.seconds <= 0:
            if tdiff.seconds % 2 and not self.blink:
                self.sprites.remove(self.text)
                self.blink = True
            elif self.blink:
                self.sprites.add(self.text)
                self.blink = False
        else:
            h, rem = divmod(tdiff.seconds, 3600)
            m, s = divmod(rem, 60)
            mls = tdiff.microseconds // 1000
            
            self.text.set_text("{:0>1}:{:0>2}:{:0>2}.{:0>3} REMAIN".format(
                h, m, s, mls))

        super().loop()

GAME = Countdown
<commit_msg>Fix timer<commit_after>import graphics
import time
import datetime
import game

class Countdown(game.Game):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.timer = graphics.Rectangle(112, 7, x=0, y=8)
        self.text = graphics.TextSprite("1:00:00.000 REMAIN", x=0, y=0, width=5, height=7)
        self.end_time = datetime.datetime(2015, 4, 12, 10, 0, 0)
        #self.end_time = datetime.datetime(2015, 4, 12, 9, 53, 0)

        self.sprites.add(self.timer)
        self.sprites.add(self.text)

        self.framerate = 100
        self.light = False
        self.blink = False

    def loop(self):
        tdiff = self.end_time - datetime.datetime.now()

        if not self.light and tdiff.seconds <= 900:
            self.light = True
            self.trigger("alert", "on")

        if tdiff.seconds <= 0:
            if tdiff.seconds % 2 and not self.blink:
                self.sprites.remove(self.text)
                self.sprites.add(self.timer)
                self.blink = True
            elif self.blink:
                self.sprites.add(self.text)
                self.sprites.remove(self.timer)
                self.blink = False
        else:
            h, rem = divmod(tdiff.seconds, 3600)
            m, s = divmod(rem, 60)
            mls = tdiff.microseconds // 1000
            
            self.text.set_text("{:0>1}:{:0>2}:{:0>2}.{:0>3} REMAIN".format(
                h, m, s, mls))
        self.timer.width = max(0,int(112 * tdiff.secods / 3600))

        super().loop()

GAME = Countdown

{'fraction_non_alphanumeric': 0.13523489932885907, 'fraction_numerical': 0.04697986577181208, 'mean_word_length': 1.8202459791863765, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '891327', 'n_tokens_mistral': 1095, 'n_tokens_neox': 974, 'n_words': 213}