ENH: debug msgs on which template was taken (+ use "is" for None comparisons)

pull/98/head
Yaroslav Halchenko 2012-12-11 11:06:03 -05:00
parent 2b6366656f
commit d1625253eb
1 changed files with 5 additions and 3 deletions

View File

@ -77,7 +77,7 @@ class DateDetector:
# previous one but with year given by 2 digits
# (See http://bugs.debian.org/537610)
template = DateStrptime()
template.setName("Day/Month/Year Hour:Minute:Second")
template.setName("Day/Month/Year2 Hour:Minute:Second")
template.setRegex("\d{2}/\d{2}/\d{2} \d{2}:\d{2}:\d{2}")
template.setPattern("%d/%m/%y %H:%M:%S")
self.__templates.append(template)
@ -158,7 +158,8 @@ class DateDetector:
try:
for template in self.__templates:
match = template.matchDate(line)
if not match == None:
if not match is None:
logSys.debug("Matched time template %s" % template.getName())
return match
return None
finally:
@ -170,8 +171,9 @@ class DateDetector:
for template in self.__templates:
try:
date = template.getDate(line)
if date == None:
if date is None:
continue
logSys.debug("Got time using template %s" % template.getName())
return date
except ValueError:
pass