From: zonidjan Date: Fri, 23 Jul 2021 05:35:02 +0000 (-0500) Subject: trivia - py3 compat X-Git-Url: https://jfr.im/git/erebus.git/commitdiff_plain/4241f9b1d8ea61e12edb7d488251dca5891cc6e5?ds=sidebyside;hp=a148e37fa5bebe6d0807d076f3deeab6dd28452b trivia - py3 compat --- diff --git a/modules/trivia.py b/modules/trivia.py index 8abc9ff..f367749 100644 --- a/modules/trivia.py +++ b/modules/trivia.py @@ -169,7 +169,7 @@ class TriviaState(object): if self.hintstr is None or self.revealpossibilities is None or self.reveal is None: oldhintstr = "" self.hintstr = list(re.sub(r'[a-zA-Z0-9]', '*', answer)) - self.revealpossibilities = range(''.join(self.hintstr).count('*')) + self.revealpossibilities = list(range(''.join(self.hintstr).count('*'))) self.reveal = int(round(''.join(self.hintstr).count('*') * (7/24.0))) else: oldhintstr = ''.join(self.hintstr) @@ -244,7 +244,7 @@ class TriviaState(object): insertpos = f.tell() fcontents = f.read() f.seek(insertpos) - f.write((self.db['hofformat']+"\n") % { + new_line = self.db['hofformat'] % { 'date': time.strftime("%F", time.gmtime()), 'duration': str(datetime.timedelta(seconds=time.time()-self.db['lastwon'])), 'targetscore': self.db['target'], @@ -254,10 +254,14 @@ class TriviaState(object): 'secondscore': pts(1), 'thirdperson': person(2), 'thirdscore': pts(2), - }) + } + f.write(new_line.encode() + b"\n") f.write(fcontents) status = True except Exception as e: + print(repr(e)) + print(type(e)) + print(e.message) status = False finally: if f is not None: