Take advantage of refactored functionality in EventType and EventRoleType
svn: r13861
This commit is contained in:
parent
dcb926bf87
commit
f4ca61c117
@ -41,8 +41,6 @@ from gettext import gettext as _
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import DateHandler
|
||||
from gen.lib.eventroletype import EventRoleType
|
||||
from gen.lib.eventtype import EventType
|
||||
from Utils import media_path_full
|
||||
from gen.plug.docgen import IndexMark, INDEX_TYPE_ALP
|
||||
|
||||
@ -163,8 +161,8 @@ def find_spouse(person, family):
|
||||
def find_marriage(database, family):
|
||||
for event_ref in family.get_event_ref_list():
|
||||
event = database.get_event_from_handle(event_ref.ref)
|
||||
if event and event.type.value == EventType.MARRIAGE \
|
||||
and event_ref.role.value == EventRoleType.FAMILY:
|
||||
if (event and event.type.is_marriage() and
|
||||
event_ref.role.is_family()):
|
||||
return event
|
||||
return None
|
||||
|
||||
@ -175,8 +173,8 @@ def get_birth_or_fallback(database, person):
|
||||
# now search the event list for fallbacks
|
||||
for event_ref in person.get_primary_event_ref_list():
|
||||
event = database.get_event_from_handle(event_ref.ref)
|
||||
if event.type.value in [EventType.CHRISTEN, EventType.BAPTISM] \
|
||||
and event_ref.role.value == EventRoleType.PRIMARY:
|
||||
if (event.type.is_birth_fallback() and
|
||||
event_ref.role.is_primary()):
|
||||
return event
|
||||
return None
|
||||
|
||||
@ -187,10 +185,8 @@ def get_death_or_fallback(database, person):
|
||||
# now search the event list for fallbacks
|
||||
for event_ref in person.get_primary_event_ref_list():
|
||||
event = database.get_event_from_handle(event_ref.ref)
|
||||
if (event.type.value in [EventType.BURIAL,
|
||||
EventType.CREMATION,
|
||||
EventType.CAUSE_DEATH]
|
||||
and event_ref.role.value == EventRoleType.PRIMARY):
|
||||
if (event.type.is_death_fallback() and
|
||||
event_ref.role.is_primary()):
|
||||
return event
|
||||
return None
|
||||
|
||||
|
22
src/Utils.py
22
src/Utils.py
@ -479,7 +479,7 @@ def probably_alive(person, db, current_date=None, limit=0):
|
||||
# If the recorded death year is before current year then
|
||||
# things are simple.
|
||||
death_ref = person.get_death_ref()
|
||||
if death_ref and death_ref.get_role() == gen.lib.EventRoleType.PRIMARY:
|
||||
if death_ref and death_ref.get_role().is_primary():
|
||||
# If they have a prmary death ref
|
||||
if now:
|
||||
# If you are asking today, then they are dead
|
||||
@ -494,10 +494,8 @@ def probably_alive(person, db, current_date=None, limit=0):
|
||||
# These are fairly good indications that someone's not alive.
|
||||
for ev_ref in person.get_primary_event_ref_list():
|
||||
ev = db.get_event_from_handle(ev_ref.ref)
|
||||
if ev and ev.type in [gen.lib.EventType.CAUSE_DEATH,
|
||||
gen.lib.EventType.BURIAL,
|
||||
gen.lib.EventType.CREMATION]:
|
||||
# If they have a prmary death-related event
|
||||
if ev and ev.type.is_death_fallback():
|
||||
# If they have a primary death-related event
|
||||
if now:
|
||||
# If you are asking today, then they are dead
|
||||
return False
|
||||
@ -515,7 +513,7 @@ def probably_alive(person, db, current_date=None, limit=0):
|
||||
# If they were born within 100 years before current year then
|
||||
# assume they are alive (we already know they are not dead).
|
||||
birth_ref = person.get_birth_ref()
|
||||
if birth_ref and birth_ref.get_role() == gen.lib.EventRoleType.PRIMARY:
|
||||
if birth_ref and birth_ref.get_role().is_primary():
|
||||
birth = db.get_event_from_handle(birth_ref.ref)
|
||||
if (birth.get_date_object().get_start_date() != gen.lib.Date.EMPTY):
|
||||
if not birth_date:
|
||||
@ -631,7 +629,7 @@ def probably_alive(person, db, current_date=None, limit=0):
|
||||
if father_handle:
|
||||
father = db.get_person_from_handle(father_handle)
|
||||
father_birth_ref = father.get_birth_ref()
|
||||
if father_birth_ref and father_birth_ref.get_role() == gen.lib.EventRoleType.PRIMARY:
|
||||
if father_birth_ref and father_birth_ref.get_role().is_primary():
|
||||
father_birth = db.get_event_from_handle(
|
||||
father_birth_ref.ref)
|
||||
dobj = father_birth.get_date_object()
|
||||
@ -640,7 +638,7 @@ def probably_alive(person, db, current_date=None, limit=0):
|
||||
return True
|
||||
|
||||
father_death_ref = father.get_death_ref()
|
||||
if father_death_ref and father_death_ref.get_role() == gen.lib.EventRoleType.PRIMARY:
|
||||
if father_death_ref and father_death_ref.get_role().is_primary():
|
||||
father_death = db.get_event_from_handle(
|
||||
father_death_ref.ref)
|
||||
dobj = father_death.get_date_object()
|
||||
@ -655,7 +653,7 @@ def probably_alive(person, db, current_date=None, limit=0):
|
||||
if mother_handle:
|
||||
mother = db.get_person_from_handle(mother_handle)
|
||||
mother_birth_ref = mother.get_birth_ref()
|
||||
if mother_birth_ref and mother_birth_ref.get_role() == gen.lib.EventRoleType.PRIMARY:
|
||||
if mother_birth_ref and mother_birth_ref.get_role().is_primary():
|
||||
mother_birth = db.get_event_from_handle(mother_birth_ref.ref)
|
||||
dobj = mother_birth.get_date_object()
|
||||
if dobj.get_start_date() != gen.lib.Date.EMPTY:
|
||||
@ -663,7 +661,7 @@ def probably_alive(person, db, current_date=None, limit=0):
|
||||
return True
|
||||
|
||||
mother_death_ref = mother.get_death_ref()
|
||||
if mother_death_ref and mother_death_ref.get_role() == gen.lib.EventRoleType.PRIMARY:
|
||||
if mother_death_ref and mother_death_ref.get_role().is_primary():
|
||||
mother_death = db.get_event_from_handle(
|
||||
mother_death_ref.ref)
|
||||
dobj = mother_death.get_date_object()
|
||||
@ -1042,7 +1040,7 @@ def get_participant_from_event(db, event_handle):
|
||||
person = db.get_person_from_handle(personhandle)
|
||||
for event_ref in person.get_event_ref_list():
|
||||
if event_handle == event_ref.ref and \
|
||||
event_ref.get_role() == gen.lib.EventRoleType.PRIMARY:
|
||||
event_ref.get_role().is_primary():
|
||||
if participant:
|
||||
ellipses = True
|
||||
else:
|
||||
@ -1057,7 +1055,7 @@ def get_participant_from_event(db, event_handle):
|
||||
family = db.get_family_from_handle(familyhandle)
|
||||
for event_ref in family.get_event_ref_list():
|
||||
if event_handle == event_ref.ref and \
|
||||
event_ref.get_role() == gen.lib.EventRoleType.FAMILY:
|
||||
event_ref.get_role().is_family():
|
||||
if participant:
|
||||
ellipses = True
|
||||
else:
|
||||
|
@ -35,7 +35,7 @@ from TransUtils import sgettext as _
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
import gen.lib
|
||||
from gen.lib import ChildRefType, Date, EventType, Name, EventRoleType
|
||||
from gen.lib import ChildRefType, Date, Name
|
||||
from gen.plug.docgen import FontStyle, ParagraphStyle, FONT_SANS_SERIF
|
||||
from BasicUtils import name_displayer
|
||||
from gen.plug import Gramplet
|
||||
@ -69,9 +69,7 @@ def _find_death_date(db, person):
|
||||
event_list = person.get_primary_event_ref_list()
|
||||
for event_ref in event_list:
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if (event.get_type() == EventType.BURIAL or
|
||||
event.get_type() == EventType.CAUSE_DEATH or
|
||||
event.get_type() == EventType.CREMATION):
|
||||
if event.get_type().is_death_fallback():
|
||||
return event.get_date_object()
|
||||
return None
|
||||
|
||||
@ -137,13 +135,13 @@ def _find_records(db, filter, callname):
|
||||
divorce_date = None
|
||||
for event_ref in family.get_event_ref_list():
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if event.get_type() == gen.lib.EventType.MARRIAGE and \
|
||||
(event_ref.get_role() == gen.lib.EventRoleType.FAMILY or
|
||||
event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ):
|
||||
if (event.get_type().is_marriage() and
|
||||
(event_ref.get_role().is_family() or
|
||||
event_ref.get_role().is_primary())):
|
||||
marriage_date = event.get_date_object()
|
||||
elif event.get_type() == gen.lib.EventType.DIVORCE and \
|
||||
(event_ref.get_role() == gen.lib.EventRoleType.FAMILY or
|
||||
event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ):
|
||||
elif (event.get_type().is_divorce() and
|
||||
(event_ref.get_role().is_family() or
|
||||
event_ref.get_role().is_primary())):
|
||||
divorce_date = event.get_date_object()
|
||||
|
||||
if _good_date(marriage_date):
|
||||
@ -225,13 +223,13 @@ def _find_records(db, filter, callname):
|
||||
divorce_date = None
|
||||
for event_ref in family.get_event_ref_list():
|
||||
event = db.get_event_from_handle(event_ref.ref)
|
||||
if event.get_type() == gen.lib.EventType.MARRIAGE and \
|
||||
(event_ref.get_role() == gen.lib.EventRoleType.FAMILY or
|
||||
event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ):
|
||||
if (event.get_type().is_marriage() and
|
||||
(event_ref.get_role().is_family() or
|
||||
event_ref.get_role().is_primary())):
|
||||
marriage_date = event.get_date_object()
|
||||
if event and event.get_type() == gen.lib.EventType.DIVORCE and \
|
||||
(event_ref.get_role() == gen.lib.EventRoleType.FAMILY or
|
||||
event_ref.get_role() == gen.lib.EventRoleType.PRIMARY ):
|
||||
if (event and event.get_type().is_divorce() and
|
||||
(event_ref.get_role().is_family() or
|
||||
event_ref.get_role().is_primary())):
|
||||
divorce_date = event.get_date_object()
|
||||
|
||||
father_death_date = _find_death_date(db, father)
|
||||
|
Loading…
Reference in New Issue
Block a user