]> jfr.im git - erebus.git/commitdiff
trivia - py3 compat
authorzonidjan <redacted>
Fri, 23 Jul 2021 05:35:02 +0000 (00:35 -0500)
committerzonidjan <redacted>
Fri, 23 Jul 2021 05:35:02 +0000 (00:35 -0500)
modules/trivia.py

index 8abc9ff7230467d09e15a48575424786760ab7b9..f36774926c6a7f0e766fc3fd1874ccaf59462f31 100644 (file)
@@ -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: