Event types know how to abbreviate themselves
svn: r13898
This commit is contained in:
parent
80c53cce3d
commit
302781a6b3
@ -29,7 +29,8 @@ Provide the different event types
|
||||
# Python modules
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
from TransUtils import sgettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
@ -187,6 +188,12 @@ class EventType(GrampsType):
|
||||
(MARR_ALT , _("Alternate Marriage"), "Alternate Marriage"),
|
||||
]
|
||||
|
||||
_ABBREVIATIONS = {
|
||||
BIRTH: _("birth abbreviation|b"),
|
||||
DEATH: _("death abbreviation|d"),
|
||||
MARRIAGE: _("marriage abbreviation|m"),
|
||||
}
|
||||
|
||||
def __init__(self, value=None):
|
||||
GrampsType.__init__(self, value)
|
||||
|
||||
@ -231,3 +238,18 @@ class EventType(GrampsType):
|
||||
Returns True if EventType is DIVORCE, False otherwise.
|
||||
"""
|
||||
return self.value == self.DIVORCE
|
||||
|
||||
def get_abbreviation(self):
|
||||
"""
|
||||
Returns the abbreviation for this event. Uses the explicitly
|
||||
given abbreviations, or first letter of each word, or the first
|
||||
three letters. Appends a period after the abbreviation.
|
||||
"""
|
||||
if self.value in self._ABBREVIATIONS:
|
||||
return self._ABBREVIATIONS[self.value] + "."
|
||||
else:
|
||||
abbrev = str(self)
|
||||
if " " in abbrev:
|
||||
return ".".join([letter[0].lower() for letter in abbrev.split()]) + "."
|
||||
else:
|
||||
return abbrev[:3].lower() + "."
|
||||
|
@ -40,6 +40,7 @@ from gen.plug import Gramplet
|
||||
from ReportBase import ReportUtils
|
||||
from BasicUtils import name_displayer
|
||||
import DateHandler
|
||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
||||
|
||||
class DescendantGramplet(Gramplet):
|
||||
def init(self):
|
||||
@ -69,21 +70,14 @@ class DescendantGramplet(Gramplet):
|
||||
self.append_text("", scroll_to="begin")
|
||||
|
||||
def dump_dates(self, person):
|
||||
birth_date = ""
|
||||
birth_ref = person.get_birth_ref()
|
||||
if birth_ref:
|
||||
birth = self.dbstate.db.get_event_from_handle(birth_ref.ref)
|
||||
birth_date = DateHandler.get_date(birth)
|
||||
else:
|
||||
birth = None
|
||||
birth = get_birth_or_fallback(self.dbstate.db, person)
|
||||
death = get_death_or_fallback(self.dbstate.db, person)
|
||||
|
||||
death_date = ""
|
||||
death_ref = person.get_death_ref()
|
||||
if death_ref:
|
||||
death = self.dbstate.db.get_event_from_handle(death_ref.ref)
|
||||
if birth:
|
||||
birth_date = DateHandler.get_date(birth)
|
||||
|
||||
if death:
|
||||
death_date = DateHandler.get_date(death)
|
||||
else:
|
||||
death = None
|
||||
|
||||
if birth or death:
|
||||
self.append_text(' (')
|
||||
@ -104,12 +98,14 @@ class DescendantGramplet(Gramplet):
|
||||
|
||||
if birth:
|
||||
if birth_place:
|
||||
self.append_text(_("b. %(birth_date)s - %(place)s") % {
|
||||
self.append_text(_("%(event_abbrev)s %(birth_date)s - %(place)s") % {
|
||||
'event_abbrev': birth.type.get_abbreviation(),
|
||||
'birth_date' : birth_date,
|
||||
'place' : birth_place,
|
||||
})
|
||||
else:
|
||||
self.append_text(_("b. %(birth_date)s") % {
|
||||
self.append_text(_("%(event_abbrev)s %(birth_date)s") % {
|
||||
'event_abbrev': birth.type.get_abbreviation(),
|
||||
'birth_date' : birth_date
|
||||
})
|
||||
|
||||
@ -117,12 +113,14 @@ class DescendantGramplet(Gramplet):
|
||||
if birth:
|
||||
self.append_text(', ')
|
||||
if death_place:
|
||||
self.append_text(_("d. %(death_date)s - %(place)s") % {
|
||||
self.append_text(_("%(event_abbrev)s %(death_date)s - %(place)s") % {
|
||||
'event_abbrev': death.type.get_abbreviation(),
|
||||
'death_date' : death_date,
|
||||
'place' : death_place,
|
||||
})
|
||||
else:
|
||||
self.append_text(_("d. %(death_date)s") % {
|
||||
self.append_text(_("%(event_abbrev)s %(death_date)s") % {
|
||||
'event_abbrev': death.type.get_abbreviation(),
|
||||
'death_date' : death_date
|
||||
})
|
||||
|
||||
|
@ -48,9 +48,6 @@ import DateHandler
|
||||
import Sort
|
||||
from gen.utils import get_birth_or_fallback, get_death_or_fallback
|
||||
|
||||
_BORN = _('b.')
|
||||
_DIED = _('d.')
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# DescendantReport
|
||||
@ -98,12 +95,14 @@ class DescendantReport(Report):
|
||||
if bplace_handle:
|
||||
birth_place = self.database.get_place_from_handle(
|
||||
bplace_handle).get_title()
|
||||
self.doc.write_text(_("b. %(birth_date)s - %(place)s") % {
|
||||
self.doc.write_text(_("%(event_abbrev)s %(birth_date)s - %(place)s") % {
|
||||
'event_abbrev': birth.type.get_abbreviation(),
|
||||
'birth_date' : birth_date,
|
||||
'place' : birth_place,
|
||||
})
|
||||
else:
|
||||
self.doc.write_text(_("b. %(birth_date)s") % {
|
||||
self.doc.write_text(_("%(event_abbrev)s %(birth_date)s") % {
|
||||
'event_abbrev': birth.type.get_abbreviation(),
|
||||
'birth_date' : birth_date
|
||||
})
|
||||
|
||||
@ -115,12 +114,14 @@ class DescendantReport(Report):
|
||||
if dplace_handle:
|
||||
death_place = self.database.get_place_from_handle(
|
||||
dplace_handle).get_title()
|
||||
self.doc.write_text(_("d. %(death_date)s - %(place)s") % {
|
||||
self.doc.write_text(_("%(event_abbrev)s %(death_date)s - %(place)s") % {
|
||||
'event_abbrev': death.type.get_abbreviation(),
|
||||
'death_date' : death_date,
|
||||
'place' : death_place,
|
||||
})
|
||||
else:
|
||||
self.doc.write_text(_("d. %(death_date)s") % {
|
||||
self.doc.write_text(_("%(event_abbrev)s %(death_date)s") % {
|
||||
'event_abbrev': death.type.get_abbreviation(),
|
||||
'death_date' : death_date
|
||||
})
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user