Fixed handling of random text

svn: r189
This commit is contained in:
Don Allingham 2001-06-26 14:19:35 +00:00
parent 2a6dcf601d
commit 7d3b6d8873

View File

@ -409,7 +409,7 @@ class SingleDate:
def setMonthStr(self,text): def setMonthStr(self,text):
try: try:
self.month = SingleDate.m2num[string.lower(text[0:3])] self.month = SingleDate.m2num[string.lower(text[0:3])]
except: except KeyError:
self.month = -1 self.month = -1
#-------------------------------------------------------------------- #--------------------------------------------------------------------
@ -420,7 +420,7 @@ class SingleDate:
def setMonthStrEng(self,text): def setMonthStrEng(self,text):
try: try:
self.month = SingleDate.em2num[string.lower(text[0:3])] self.month = SingleDate.em2num[string.lower(text[0:3])]
except: except KeyError:
self.month = -1 self.month = -1
#-------------------------------------------------------------------- #--------------------------------------------------------------------
@ -751,6 +751,8 @@ class SingleDate:
matches = match.groups() matches = match.groups()
self.getMode(matches[0]) self.getMode(matches[0])
self.setMonthStr(matches[2]) self.setMonthStr(matches[2])
if self.month == -1:
raise Date.Error,text
self.day = int(matches[1]) self.day = int(matches[1])
if len(matches) == 4: if len(matches) == 4:
val = matches[3] val = matches[3]
@ -825,6 +827,8 @@ class SingleDate:
matches = match.groups() matches = match.groups()
self.getMode(matches[0]) self.getMode(matches[0])
self.setMonthStr(matches[1]) self.setMonthStr(matches[1])
if self.month == -1:
raise Date.Error,text
val = matches[2] val = matches[2]
if val: if val:
self.day = int(string.replace(val,',','')) self.day = int(string.replace(val,',',''))
@ -842,6 +846,8 @@ class SingleDate:
matches = match.groups() matches = match.groups()
self.getMode(matches[0]) self.getMode(matches[0])
self.setMonthStr(matches[1]) self.setMonthStr(matches[1])
if self.month == -1:
raise Date.Error,text
self.day = -1 self.day = -1
if len(matches) == 4: if len(matches) == 4:
val = matches[3] val = matches[3]
@ -875,6 +881,8 @@ class SingleDate:
matches = match.groups() matches = match.groups()
self.setMode(matches[0]) self.setMode(matches[0])
self.setMonthStrEng(matches[2]) self.setMonthStrEng(matches[2])
if self.month == -1:
raise Date.Error,text
self.day = int(matches[1]) self.day = int(matches[1])
if len(matches) == 4: if len(matches) == 4:
val = matches[3] val = matches[3]
@ -935,6 +943,8 @@ if __name__ == "__main__":
Date.entryCode = 1 Date.entryCode = 1
checkit("1/12/1999") checkit("1/12/1999")
checkit("12/11/1999") checkit("12/11/1999")
checkit("summer")
print "----------"
checkit("BET. 1994 - 1999") checkit("BET. 1994 - 1999")