* src/DateParser.py: dynamically detect numerical parsing based

off locale. Do not depend on strptime.
* src/Utils.py: remove last remains of SingleDate
* src/PeopleModel.py: display "error" instead of a blank string
on an error
* src/EventEdit.py: removed unused parameter
* src/Exporter.py: remove unused gnome.ui import
* src/plugins/FanChart.py: remove old Calendar reference
* src/plugins/Verify.py: remove old Calendar reference


svn: r3620
This commit is contained in:
Don Allingham 2004-10-12 01:29:39 +00:00
parent d0a04be93f
commit 45504a5025
8 changed files with 38 additions and 22 deletions

View File

@ -1,3 +1,14 @@
2004-10-11 Don Allingham <dallingham@users.sourceforge.net>
* src/DateParser.py: dynamically detect numerical parsing based
off locale. Do not depend on strptime.
* src/Utils.py: remove last remains of SingleDate
* src/PeopleModel.py: display "error" instead of a blank string
on an error
* src/EventEdit.py: removed unused parameter
* src/Exporter.py: remove unused gnome.ui import
* src/plugins/FanChart.py: remove old Calendar reference
* src/plugins/Verify.py: remove old Calendar reference
2004-10-11 Alex Roitman <shura@alex.neuro.umn.edu>
* src/DateDisplay.py (_display_gregorian): Prepend month and
day with zeros if needed for the ISO format.

View File

@ -58,6 +58,7 @@ class DateParser:
# determine the code set returned by nl_langinfo
_codeset = locale.nl_langinfo(locale.CODESET)
_fmt_parse = re.compile(".*%(\S).*%(\S).*%(\S).*")
# RFC-2822 only uses capitalized English abbreviated names, no locales.
_rfc_days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat')
@ -246,6 +247,13 @@ class DateParser:
Date.CAL_ISLAMIC : self._parse_islamic,
}
fmt = locale.nl_langinfo(locale.D_FMT)
match = self._fmt_parse.match(fmt.lower())
if match:
self.dmy = (match.groups() == ('d','m','y'))
else:
self.dmy = True
def _get_int(self,val):
"""
Converts the string to an integer if the value is not None. If the
@ -321,12 +329,6 @@ class DateParser:
if subparser == None:
subparser = self._parse_greg_julian
try:
value = time.strptime(text)
return (value[2],value[1],value[0],False)
except ValueError:
pass
value = subparser(text)
if value != Date.EMPTY:
return value
@ -356,6 +358,10 @@ class DateParser:
match = self._numeric.match(text)
if match:
groups = match.groups()
if self.dmy:
m = self._get_int(groups[3])
d = self._get_int(groups[1])
else:
m = self._get_int(groups[1])
d = self._get_int(groups[3])
y = self._get_int(groups[4])

View File

@ -272,7 +272,7 @@ class EventEditor:
"""Display the relevant portion of GRAMPS manual"""
gnome.help_display('gramps-manual','gramps-edit-complete')
def get_place(self,field,trans):
def get_place(self,field):
text = strip(unicode(field.get_text()))
if text:
if self.pmap.has_key(text):
@ -289,7 +289,7 @@ class EventEditor:
ename = unicode(self.event_menu.child.get_text())
#self.date = self.dp.parse(unicode(self.date_field.get_text()))
ecause = unicode(self.cause_field.get_text())
eplace_obj = self.get_place(self.place_field,trans)
eplace_obj = self.get_place(self.place_field)
buf = self.note_field.get_buffer()
enote = unicode(buf.get_text(buf.get_start_iter(),buf.get_end_iter(),gtk.FALSE))

View File

@ -40,6 +40,7 @@ from gettext import gettext as _
#-------------------------------------------------------------------------
import gtk
import gnome
import gnome.ui
#-------------------------------------------------------------------------
#

View File

@ -178,8 +178,7 @@ class PeopleModel(gtk.GenericTreeModel):
try:
return COLUMN_DEFS[col][COLUMN_DEF_LIST](self,self.db.person_map[str(node)],node)
except:
print "except"
return u''
return u'error'
def reset_visible(self):
self.visible = {}

View File

@ -647,16 +647,16 @@ def probably_alive(person,db):
sp_death_handle = spouse.get_death_handle()
if sp_birth_handle:
spouse_birth = db.get_event_from_handle(sp_birth_handle)
if spouse_birth.get_date() != "":
d = SingleDate (spouse_birth.get_date_object().get_start_date())
d.set_year (d.get_year() + max_age_difference)
if not spouse_birth.get_date().is_empty():
d = Date(spouse_birth.get_date_object())
d.set_year(d.get_year() + max_age_difference)
if not not_too_old (d):
return False
if sp_death_handle:
spouse_death = db.get_event_from_handle(sp_death_handle)
if spouse_death.get_date() != "":
d = SingleDate (spouse_death.get_date_object().get_start_date())
d = Date(spouse_death.get_date_object())
d.set_year (d.get_year() - min_generation)
if not not_too_old (d):
return False

View File

@ -35,7 +35,7 @@ import gtk
import BaseDoc
import Report
import Errors
import Calendar
import Date
from QuestionDialog import ErrorDialog
from SubstKeywords import SubstKeywords
@ -206,7 +206,7 @@ class FanChart:
birth_handle = person.get_birth_handle()
if birth_handle:
b = self.database.get_event_from_handle(birth_handle).get_date_object().get_year()
if b == Calendar.UNDEF:
if b == 0:
b = ""
else:
b = ""
@ -214,7 +214,7 @@ class FanChart:
death_handle = person.get_death_handle()
if death_handle:
d = self.database.get_event_from_handle(death_handle).get_date_object().get_year()
if d == Calendar.UNDEF:
if d == 0:
d = ""
else:
d = ""

View File

@ -50,7 +50,6 @@ import gtk.glade
#------------------------------------------------------------------------
import RelLib
import Utils
import Gregorian
from gettext import gettext as _
@ -117,8 +116,8 @@ class Verify:
event = self.db.get_event_from_handle(event_handle)
dateObj = event.get_date_object()
if dateObj:
if dateObj.get_calendar().NAME != Gregorian.Gregorian.NAME:
dateObj.set_calendar(Gregorian.Gregorian)
if dateObj.get_calendar() != Date.CAL_GREGORIAN:
dateObj.set_calendar(Date.CAL_GREGORIAN)
year = dateObj.get_year()
return year