* src/DateParser.py: Minor cleanup.

svn: r3553
This commit is contained in:
Alex Roitman 2004-09-18 04:11:48 +00:00
parent b4ab304891
commit b66cf9e5f0
2 changed files with 4 additions and 8 deletions

View File

@ -5,6 +5,7 @@
* src/AddrEdit.py: Use date editor callback.
* src/EditPerson.py: Use date editor callback.
* src/EventEdit.py: Use date editor callback.
* src/DateParser.py: Minor cleanup.
2004-09-17 Don Allingham <dallingham@users.sourceforge.net>
* src/DateDisplay.py: use locale.nl_langinfo to get month

View File

@ -26,7 +26,6 @@ date parsing class.
__author__ = "Donald N. Allingham"
__version__ = "$Revision$"
import string
import re
import time
import locale
@ -100,9 +99,7 @@ class DateParser:
_mod_str = '(' + '|'.join(
[ key.replace('.','\.') for key in modifier_to_int.keys() ]
) + ')'
_qual_str = '(' + string.join(quality_to_int.keys(),'|') + ')'
_mod_str = '(' + string.join(modifier_to_int.keys(),'|') + ')'
_mon_str = '(' + string.join(month_to_int.keys(),'|') + ')'
_mon_str = '(' + '|'.join(month_to_int.keys()) + ')'
_qual = re.compile("%s\s+(.*)" % _qual_str,re.IGNORECASE)
_span = re.compile("from\s+(.*)\s+to\s+(.*)",re.IGNORECASE)
@ -189,7 +186,7 @@ class DateParser:
def set_date(self,date,text):
"""
Parses the text, returning a Date object.
Parses the text and sets the date according to the parsing.
"""
date.set_text_value(text)
qual = Date.QUAL_NONE
@ -222,7 +219,7 @@ class DateParser:
start = self._parse_subdate(grps[1])
mod = self.modifier_to_int.get(grps[0].lower(),Date.MOD_NONE)
date.set(qual,mod,Date.CAL_GREGORIAN,start)
return date
return
subdate = self._parse_subdate(text)
if subdate == Date.EMPTY:
@ -237,5 +234,3 @@ class DateParser:
new_date = Date.Date()
self.set_date(new_date,text)
return new_date