* src/DateDisplay.py (display): Display text for text-only dates.
Closes # 1036846. * src/plugins/Merge.py (date_match,range_compare): Use new Date API. Closes # 1036852. * src/plugins/WebPage.py: Use new Date API. Use correct module for gconf keys access. Closes # 1036856. * src/Sort.py (by_date): Use new Date API. * src/plugins/AncestorReport.py: Use new Date API. Closes # 1036858. * src/plugins/Ancestor.py: Correct use of handles. Use new Date API. Closes # 1036859. svn: r3593
This commit is contained in:
parent
9db7068e7e
commit
3714eb6ef0
@ -1,3 +1,15 @@
|
||||
2004-10-02 Alex Roitman <shura@alex.neuro.umn.edu>
|
||||
* src/DateDisplay.py (display): Display text for text-only dates.
|
||||
Closes # 1036846.
|
||||
* src/plugins/Merge.py (date_match,range_compare): Use new
|
||||
Date API. Closes # 1036852.
|
||||
* src/plugins/WebPage.py: Use new Date API. Use correct module
|
||||
for gconf keys access. Closes # 1036856.
|
||||
* src/Sort.py (by_date): Use new Date API.
|
||||
* src/plugins/AncestorReport.py: Use new Date API. Closes # 1036858.
|
||||
* src/plugins/Ancestor.py: Correct use of handles.
|
||||
Use new Date API. Closes # 1036859.
|
||||
|
||||
2004-09-30 Don Allingham <dallingham@users.sourceforge.net>
|
||||
* src/EditPerson.py: enhanced update/delete/add of person view
|
||||
* src/PeopleModel.py: enhanced update/delete/add of person view
|
||||
|
@ -178,9 +178,11 @@ class DateDisplay:
|
||||
|
||||
qual_str = self._qual_str[qual]
|
||||
|
||||
if start == Date.EMPTY:
|
||||
if mod == Date.MOD_TEXTONLY:
|
||||
return date.get_text()
|
||||
elif start == Date.EMPTY:
|
||||
return u""
|
||||
if mod == Date.MOD_SPAN:
|
||||
elif mod == Date.MOD_SPAN:
|
||||
d1 = self.display_cal[cal](start)
|
||||
d2 = self.display_cal[cal](date.get_stop_date())
|
||||
return "%sfrom %s to %s%s" % (qual_str,d1,d2,self.calendar[cal])
|
||||
|
@ -104,4 +104,4 @@ class Sort:
|
||||
return 0
|
||||
a = self.database.get_event_from_handle(a_id)
|
||||
b = self.database.get_event_from_handle(b_id)
|
||||
return Date.compare_dates(a.get_date_object(),b.get_date_object())
|
||||
return cmp(a.get_date_object(),b.get_date_object())
|
||||
|
@ -39,9 +39,12 @@ import Report
|
||||
import BaseDoc
|
||||
import RelLib
|
||||
import Errors
|
||||
import DateHandler
|
||||
from QuestionDialog import ErrorDialog
|
||||
from gettext import gettext as _
|
||||
|
||||
_dd = DateHandler.create_display()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# AncestorReport
|
||||
@ -121,7 +124,8 @@ class AncestorReport(Report.Report):
|
||||
birth_handle = person.get_birth_handle()
|
||||
if birth_handle:
|
||||
birth = self.database.get_event_from_handle(birth_handle)
|
||||
date = birth.get_date_object().get_start_date()
|
||||
date = birth.get_date_object()
|
||||
date_text = _dd.display(date)
|
||||
place_handle = birth.get_place_handle()
|
||||
if place_handle:
|
||||
place = self.database.get_place_from_handle(place_handle).get_title()
|
||||
@ -129,22 +133,22 @@ class AncestorReport(Report.Report):
|
||||
place = u''
|
||||
if place[-1:] == '.':
|
||||
place = place[:-1]
|
||||
if date.get_date() != "" or place_handle:
|
||||
if date.get_date() != "":
|
||||
if date_text != "" or place_handle:
|
||||
if date_text != "":
|
||||
if date.get_day_valid() and date.get_month_valid():
|
||||
if place != "":
|
||||
t = _("%s was born on %s in %s. ") % \
|
||||
(name,date.get_date(),place)
|
||||
(name,date_text,place)
|
||||
else:
|
||||
t = _("%s was born on %s. ") % \
|
||||
(name,date.get_date())
|
||||
(name,date_text)
|
||||
else:
|
||||
if place != "":
|
||||
t = _("%s was born in the year %s in %s. ") % \
|
||||
(name,date.get_date(),place)
|
||||
(name,date_text,place)
|
||||
else:
|
||||
t = _("%s was born in the year %s. ") % \
|
||||
(name,date.get_date())
|
||||
(name,date_text)
|
||||
self.doc.write_text(t)
|
||||
|
||||
buried = None
|
||||
@ -156,7 +160,8 @@ class AncestorReport(Report.Report):
|
||||
death_handle = person.get_death_handle()
|
||||
if death_handle:
|
||||
death = self.database.get_event_from_handle(death_handle)
|
||||
date = death.get_date_object().get_start_date()
|
||||
date = death.get_date_object()
|
||||
date_text = _dd.display(date)
|
||||
place_handle = death.get_place_handle()
|
||||
if place_handle:
|
||||
place = self.database.get_place_from_handle(place_handle).get_title()
|
||||
@ -164,44 +169,45 @@ class AncestorReport(Report.Report):
|
||||
place = u''
|
||||
if place[-1:] == '.':
|
||||
place = place[:-1]
|
||||
if date.get_date() != "" or place_handle:
|
||||
if date_text != "" or place_handle:
|
||||
if person.get_gender() == RelLib.Person.male:
|
||||
male = 1
|
||||
else:
|
||||
male = 0
|
||||
|
||||
if date.get_date() != "":
|
||||
if date_text != "":
|
||||
if date.get_day_valid() and date.get_month_valid():
|
||||
if male:
|
||||
if place != "":
|
||||
t = _("He died on %s in %s") % \
|
||||
(date.get_date(),place)
|
||||
(date_text,place)
|
||||
else:
|
||||
t = _("He died on %s") % date.get_date()
|
||||
t = _("He died on %s") % date_text
|
||||
else:
|
||||
if place != "":
|
||||
t = _("She died on %s in %s") % \
|
||||
(date.get_date(),place)
|
||||
(date_text,place)
|
||||
else:
|
||||
t = _("She died on %s") % date.get_date()
|
||||
t = _("She died on %s") % date_text
|
||||
else:
|
||||
if male:
|
||||
if place != "":
|
||||
t = _("He died in the year %s in %s") % \
|
||||
(date.get_date(),place)
|
||||
(date_text,place)
|
||||
else:
|
||||
t = _("He died in the year %s") % date.get_date()
|
||||
t = _("He died in the year %s") % date_text
|
||||
else:
|
||||
if place != "":
|
||||
t = _("She died in the year %s in %s") % \
|
||||
(date.get_date(),place)
|
||||
(date_text,place)
|
||||
else:
|
||||
t = _("She died in the year %s") % date.get_date()
|
||||
t = _("She died in the year %s") % date_text
|
||||
|
||||
self.doc.write_text(t)
|
||||
|
||||
if buried:
|
||||
date = buried.get_date_object().get_start_date()
|
||||
date = buried.get_date_object()
|
||||
date_text = _dd.display(date)
|
||||
place_handle = buried.get_place_handle()
|
||||
if place_handle:
|
||||
place = self.database.get_place_from_handle(place_handle).get_title()
|
||||
@ -209,22 +215,21 @@ class AncestorReport(Report.Report):
|
||||
place = u''
|
||||
if place[-1:] == '.':
|
||||
place = place[:-1]
|
||||
if date.get_date() != "" or place_handle:
|
||||
if date.get_date() != "":
|
||||
if date_text != "" or place_handle:
|
||||
if date_text != "":
|
||||
if date.get_day_valid() and date.get_month_valid():
|
||||
if place != "":
|
||||
t = _(", and was buried on %s in %s.") % \
|
||||
(date.get_date(),place)
|
||||
(date_text,place)
|
||||
else:
|
||||
t = _(", and was buried on %s.") % \
|
||||
date.get_date()
|
||||
t = _(", and was buried on %s.") % date_text
|
||||
else:
|
||||
if place != "":
|
||||
t = _(", and was buried in the year %s in %s.") % \
|
||||
(date.get_date(),place)
|
||||
(date_text,place)
|
||||
else:
|
||||
t = _(", and was buried in the year %s.") % \
|
||||
date.get_date()
|
||||
date_text
|
||||
else:
|
||||
t = _(" and was buried in %s.") % place
|
||||
self.doc.write_text(t)
|
||||
|
@ -34,10 +34,11 @@ import BaseDoc
|
||||
import RelLib
|
||||
import Errors
|
||||
import Plugins
|
||||
import Calendar
|
||||
import DateHandler
|
||||
from QuestionDialog import ErrorDialog
|
||||
from gettext import gettext as _
|
||||
|
||||
_dd = DateHandler.create_display()
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# ComprehensiveAncestorsReport
|
||||
@ -439,20 +440,20 @@ class ComprehensiveAncestorsReport (Report.Report):
|
||||
dateobj = event.get_date_object ()
|
||||
if dateobj:
|
||||
text = dateobj.get_text()
|
||||
date_text = _dd.display(dateobj)
|
||||
if text:
|
||||
info += ' ' + text[0].lower() + text[1:]
|
||||
elif dateobj.get_valid ():
|
||||
if (dateobj.isRange () or
|
||||
dateobj.get_start_date ().getModeVal () != Calendar.EXACT):
|
||||
info += ' ' + dateobj.get_date ()
|
||||
if not dateobj.is_regular():
|
||||
info += ' ' + date_text
|
||||
elif (dateobj.get_day_valid () and
|
||||
dateobj.get_month_valid () and
|
||||
dateobj.get_year_valid ()):
|
||||
info += _(' on %(specific_date)s') % \
|
||||
{'specific_date': dateobj.get_date ()}
|
||||
{'specific_date': date_text}
|
||||
else:
|
||||
info += _(' in %(month_or_year)s') % \
|
||||
{'month_or_year': dateobj.get_date ()}
|
||||
{'month_or_year': date_text}
|
||||
|
||||
place = self.database.get_place_from_handle(event.get_place_handle())
|
||||
if place:
|
||||
@ -688,9 +689,9 @@ class ComprehensiveAncestorsReport (Report.Report):
|
||||
family = self.database.get_family_from_handle(family_handle)
|
||||
mother_handle = family.get_mother_handle ()
|
||||
mother = self.database.get_person_from_handle(mother_handle)
|
||||
for spouse_id in [family.get_father_handle (), mother_handle]:
|
||||
spouse = self.database.get_person_from_handle(spouse_id)
|
||||
if spouse_id == person.get_handle() or not spouse_id:
|
||||
for spouse_handle in [family.get_father_handle (), mother_handle]:
|
||||
spouse = self.database.get_person_from_handle(spouse_handle)
|
||||
if spouse_handle == person.get_handle() or not spouse_handle:
|
||||
continue
|
||||
|
||||
children = ''
|
||||
@ -731,37 +732,37 @@ class ComprehensiveAncestorsReport (Report.Report):
|
||||
if not first_rel:
|
||||
if gender == RelLib.Person.female:
|
||||
ret += _(' She later married %(name)s') % \
|
||||
{'name': self.person_name (spouse)}
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
else:
|
||||
ret += _(' He later married %(name)s') % \
|
||||
{'name': self.person_name (spouse)}
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
|
||||
elif (listing_children or
|
||||
spouse == mother or
|
||||
family != from_family):
|
||||
if gender == RelLib.Person.female:
|
||||
ret += _(' She married %(name)s') % \
|
||||
{'name': self.person_name (spouse)}
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
else:
|
||||
ret += _(' He married %(name)s') % \
|
||||
{'name': self.person_name (spouse)}
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
|
||||
ret += self.event_info (marriage)
|
||||
else: # Not a marriage
|
||||
if not first_rel:
|
||||
if gender == RelLib.Person.female:
|
||||
ret += _(' She later had a relationship with %(name)s') % \
|
||||
{'name': self.person_name (spouse)}
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
else:
|
||||
ret += _(' He later had a relationship with %(name)s') % \
|
||||
{'name': self.person_name (spouse)}
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
else:
|
||||
if gender == RelLib.Person.female:
|
||||
ret += _(' She had a relationship with %(name)s') % \
|
||||
{'name': self.person_name (spouse)}
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
else:
|
||||
ret += _(' He had a relationship with %(name)s') % \
|
||||
{'name': self.person_name (spouse)}
|
||||
{'name': self.person_name (spouse_handle)}
|
||||
|
||||
ret += children + '.'
|
||||
|
||||
|
@ -362,17 +362,14 @@ class Merge:
|
||||
return s1 == s2
|
||||
|
||||
def date_match(self,date1,date2):
|
||||
if date1.get_date() == "" or date2.get_date() == "":
|
||||
if date1.is_empty() == "" or date2.is_empty() == "":
|
||||
return 0
|
||||
if date1.get_date() == date2.get_date():
|
||||
if date1.is_equal(date2):
|
||||
return 1
|
||||
|
||||
if date1.is_range() or date2.is_range():
|
||||
if date1.is_compound() or date2.is_compound():
|
||||
return self.range_compare(date1,date2)
|
||||
|
||||
date1 = date1.get_start_date()
|
||||
date2 = date2.get_start_date()
|
||||
|
||||
if date1.get_year() == date2.get_year():
|
||||
if date1.get_month() == date2.get_month():
|
||||
return 0.75
|
||||
@ -384,27 +381,25 @@ class Merge:
|
||||
return -1
|
||||
|
||||
def range_compare(self,date1,date2):
|
||||
if date1.is_range() and date2.is_range():
|
||||
if date1.get_start_date() >= date2.get_start_date() and \
|
||||
date1.get_start_date() <= date2.get_stop_date() or \
|
||||
date2.get_start_date() >= date1.get_start_date() and \
|
||||
date2.get_start_date() <= date1.get_stop_date() or \
|
||||
date1.get_stop_date() >= date2.get_start_date() and \
|
||||
date1.get_stop_date() <= date2.get_stop_date() or \
|
||||
date2.get_stop_date() >= date1.get_start_date() and \
|
||||
date2.get_stop_date() <= date1.get_stop_date():
|
||||
start_date_1 = date1.get_start_date()[0:3]
|
||||
start_date_2 = date2.get_start_date()[0:3]
|
||||
stop_date_1 = date1.get_stop_date()[0:3]
|
||||
stop_date_2 = date2.get_stop_date()[0:3]
|
||||
if date1.is_compound() and date2.is_compound():
|
||||
if start_date_1 >= start_date_2 and start_date_1 <= stop_date_2 or \
|
||||
start_date_2 >= start_date_1 and start_date_2 <= stop_date_1 or \
|
||||
stop_date_1 >= start_date_2 and stop_date_1 <= stop_date_2 or \
|
||||
stop_date_2 >= start_date_1 and stop_date_2 <= stop_date_1:
|
||||
return 0.5
|
||||
else:
|
||||
return -1
|
||||
elif date2.is_range():
|
||||
if date1.get_start_date() >= date2.get_start_date() and \
|
||||
date1.get_start_date() <= date2.get_stop_date():
|
||||
elif date2.is_compound():
|
||||
if start_date_1 >= start_date_2 and start_date_1 <= stop_date_2:
|
||||
return 0.5
|
||||
else:
|
||||
return -1
|
||||
else:
|
||||
if date2.get_start_date() >= date1.get_start_date() and \
|
||||
date2.get_start_date() <= date1.get_stop_date():
|
||||
if start_date_2 >= start_date_1 and start_date_2 <= stop_date_1:
|
||||
return 0.5
|
||||
else:
|
||||
return -1
|
||||
@ -611,6 +606,7 @@ class Merge:
|
||||
if value != -1:
|
||||
chance = chance + value
|
||||
|
||||
print p1.get_gramps_id(), p2.get_gramps_id(), chance
|
||||
return chance
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -50,9 +50,9 @@ import RelLib
|
||||
import HtmlDoc
|
||||
import BaseDoc
|
||||
import const
|
||||
import GrampsCfg
|
||||
import GrampsGconfKeys
|
||||
import GenericFilter
|
||||
import Date
|
||||
import DateHandler
|
||||
import Sort
|
||||
import Report
|
||||
import Errors
|
||||
@ -71,6 +71,8 @@ _month = [
|
||||
_hline = " " # Everything is underlined, so use blank
|
||||
_BORN = _('b.')
|
||||
|
||||
_dd = DateHandler.create_display()
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# HtmlLinkDoc
|
||||
@ -232,7 +234,7 @@ class IndividualPage:
|
||||
self.write_info(base.get_title())
|
||||
self.write_info(base.get_author())
|
||||
self.write_info(base.get_publication_info())
|
||||
self.write_info(sref.get_date().get_date())
|
||||
self.write_info(_dd.display(sref.get_date()))
|
||||
self.write_info(sref.get_page())
|
||||
if self.usecomments:
|
||||
self.write_info(sref.get_text())
|
||||
@ -504,7 +506,7 @@ class IndividualPage:
|
||||
if event.get_privacy():
|
||||
continue
|
||||
name = _(event.get_name())
|
||||
date = event.get_date()
|
||||
date_text = event.get_date()
|
||||
descr = event.get_description()
|
||||
place_handle = event.get_place_handle()
|
||||
place_url = ""
|
||||
@ -517,7 +519,7 @@ class IndividualPage:
|
||||
place = ""
|
||||
srcref = event.get_source_references()
|
||||
|
||||
if date == "" and descr == "" and place == "" and len(srcref) == 0:
|
||||
if date_text == "" and descr == "" and place == "" and len(srcref) == 0:
|
||||
continue
|
||||
|
||||
if count == 0:
|
||||
@ -534,13 +536,13 @@ class IndividualPage:
|
||||
|
||||
val = []
|
||||
|
||||
if date != "":
|
||||
if date_text != "":
|
||||
if place != "":
|
||||
val.append(("%s, " % date,""))
|
||||
val.append(("%s, " % date_text,""))
|
||||
val.append((place,place_url))
|
||||
val.append((".",""))
|
||||
else:
|
||||
val.append(("%s." % date,""))
|
||||
val.append(("%s." % date_text,""))
|
||||
elif place != "":
|
||||
val.append((place,place_url))
|
||||
val.append((".",""))
|
||||
@ -569,7 +571,7 @@ class IndividualPage:
|
||||
if event == None:
|
||||
return
|
||||
name = _(event.get_name())
|
||||
date = event.get_date()
|
||||
date_text = event.get_date()
|
||||
place_handle = event.get_place_handle()
|
||||
place_url = ""
|
||||
if place_handle:
|
||||
@ -585,11 +587,11 @@ class IndividualPage:
|
||||
if place != "" and place[-1] == ".":
|
||||
place = place[0:-1]
|
||||
|
||||
if date == "" and place == "" and descr == "":
|
||||
if date_text == "" and place == "" and descr == "":
|
||||
return
|
||||
|
||||
val = []
|
||||
if date == "":
|
||||
if date_text == "":
|
||||
if place == "":
|
||||
if descr != "":
|
||||
val.append(("%s." % descr,""))
|
||||
@ -604,16 +606,16 @@ class IndividualPage:
|
||||
else:
|
||||
if place == "":
|
||||
if descr == "":
|
||||
val.append(("%s." % date,""))
|
||||
val.append(("%s." % date_text,""))
|
||||
else:
|
||||
val.append(("%s. %s." % (date,descr),""))
|
||||
val.append(("%s. %s." % (date_text,descr),""))
|
||||
else:
|
||||
if descr == "":
|
||||
val.append(("%s, " %date,""))
|
||||
val.append(("%s, " % date_text,""))
|
||||
val.append((place,place_url))
|
||||
val.append((".",""))
|
||||
else:
|
||||
val.append(("%s, " %date,""))
|
||||
val.append(("%s, " % date_text,""))
|
||||
val.append((place,place_url))
|
||||
val.append((".",""))
|
||||
val.append(("%s." % descr,""))
|
||||
@ -769,58 +771,6 @@ class WebReport(Report.Report):
|
||||
def get_progressbar_data(self):
|
||||
return (_("Generate HTML reports - GRAMPS"), _("Creating Web Pages"))
|
||||
|
||||
def make_date(self,date):
|
||||
start = date.get_start_date()
|
||||
if date.is_empty():
|
||||
val = date.get_text()
|
||||
elif date.isRange():
|
||||
val = "FROM %s TO %s" % (self.subdate(start),
|
||||
self.subdate(date.get_stop_date()))
|
||||
else:
|
||||
val = self.subdate(start)
|
||||
return val
|
||||
|
||||
def subdate(self,subdate):
|
||||
retval = ""
|
||||
day = subdate.getDay()
|
||||
mon = subdate.getMonth()
|
||||
year = subdate.getYear()
|
||||
mode = subdate.getModeVal()
|
||||
day_valid = subdate.getDayValid()
|
||||
mon_valid = subdate.getMonthValid()
|
||||
year_valid = subdate.getYearValid()
|
||||
|
||||
if not day_valid:
|
||||
try:
|
||||
if not mon_valid:
|
||||
retval = str(year)
|
||||
elif not year_valid:
|
||||
retval = _month[mon]
|
||||
else:
|
||||
retval = "%s %d" % (_month[mon],year)
|
||||
except IndexError:
|
||||
print "Month index error - %d" % mon
|
||||
retval = str(year)
|
||||
elif not mon_valid:
|
||||
retval = str(year)
|
||||
else:
|
||||
try:
|
||||
month = _month[mon]
|
||||
if not year_valid:
|
||||
retval = "%d %s ????" % (day,month)
|
||||
else:
|
||||
retval = "%d %s %d" % (day,month,year)
|
||||
except IndexError:
|
||||
print "Month index error - %d" % mon
|
||||
retval = str(year)
|
||||
if mode == Date.Calendar.ABOUT:
|
||||
retval = "ABT %s" % retval
|
||||
elif mode == Date.Calendar.BEFORE:
|
||||
retval = "BEF %s" % retval
|
||||
elif mode == Date.Calendar.AFTER:
|
||||
retval = "AFT %s" % retval
|
||||
return retval
|
||||
|
||||
def dump_gendex(self,person_handle_list,html_dir):
|
||||
fname = "%s/gendex.txt" % html_dir
|
||||
try:
|
||||
@ -846,7 +796,7 @@ class WebReport(Report.Report):
|
||||
else:
|
||||
continue
|
||||
if e:
|
||||
f.write("%s|" % self.make_date(e.get_date_object()))
|
||||
f.write("%s|" % _dd.display(e.get_date_object()))
|
||||
if e.get_place_handle():
|
||||
f.write('%s|' % self.db.get_place_from_handle(e.get_place_handle()).get_title())
|
||||
else:
|
||||
@ -1376,7 +1326,7 @@ class WebReportDialog(Report.ReportDialog):
|
||||
"""Get the name of the directory to which the target dialog
|
||||
box should default. This value can be set in the preferences
|
||||
panel."""
|
||||
return GrampsCfg.get_web_dir()
|
||||
return GrampsGconfKeys.get_web_dir()
|
||||
|
||||
def set_default_directory(self, value):
|
||||
"""Save the name of the current directory, so that any future
|
||||
@ -1386,7 +1336,7 @@ class WebReportDialog(Report.ReportDialog):
|
||||
This means that the last directory used will only be
|
||||
remembered for this session of gramps unless the user saves
|
||||
his/her preferences."""
|
||||
GrampsCfg.save_web_dir(value)
|
||||
GrampsGconfKeys.save_web_dir(value)
|
||||
|
||||
def make_default_style(self):
|
||||
"""Make the default output style for the Web Pages Report."""
|
||||
|
Loading…
Reference in New Issue
Block a user