From c6342f5305a606c64ffbf23dd02e7f69a94c3767 Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Tue, 17 May 2011 10:56:43 -0700 Subject: [PATCH] Bug fix: Refix accepting messages from non-Pesterchum users, this time keeping ? times --- memos.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/memos.py b/memos.py index 2ff467a..dad7b54 100644 --- a/memos.py +++ b/memos.py @@ -123,14 +123,20 @@ class TimeTracker(list): def setCurrent(self, timed): self.current = self.index(timed) def addRecord(self, timed): - (temporal, pcf, when) = pcfGrammar(timed - timedelta(0)) + try: + (temporal, pcf, when) = pcfGrammar(timed - timedelta(0)) + except TypeError: + (temporal, pcf, when) = pcfGrammar(mysteryTime()) if pcf == "C" or pcf == "?": return if timed in self.timerecord[pcf]: return self.timerecord[pcf].append(timed) def getRecord(self, timed): - (temporal, pcf, when) = pcfGrammar(timed - timedelta(0)) + try: + (temporal, pcf, when) = pcfGrammar(timed - timedelta(0)) + except TypeError: + (temporal, pcf, when) = pcfGrammar(mysteryTime()) if pcf == "C" or pcf == "?": return 0 if len(self.timerecord[pcf]) > 1: @@ -163,10 +169,11 @@ class TimeTracker(list): timed = self.getTime() return self.getGrammarTime(timed) def getGrammarTime(self, timed): - if not timed: - timed = timedelta(0) mytime = timedelta(0) - (temporal, pcf, when) = pcfGrammar(timed - mytime) + try: + (temporal, pcf, when) = pcfGrammar(timed - mytime) + except TypeError: + (temporal, pcf, when) = pcfGrammar(mysteryTime()) if timed == mytime: return TimeGrammar(temporal, pcf, when, 0) return TimeGrammar(temporal, pcf, when, self.getRecord(timed))