* src/DateParser.py: Minor cleanup.

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

View File

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

View File

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