2007-11-23 Benny Malengier <benny.malengier@gramps-project.org>
* src/plugins/all_relations.py: remove unnecessary import * src/plugins/siblings.py: add sibling relation if not normal * src/Relationship.py: improve sibling type calculation Issue #1323 svn: r9388
This commit is contained in:
parent
ebc943ed08
commit
36ac2f8190
@ -1,3 +1,9 @@
|
||||
2007-11-23 Benny Malengier <benny.malengier@gramps-project.org>
|
||||
* src/plugins/all_relations.py: remove unnecessary import
|
||||
* src/plugins/siblings.py: add sibling relation if not normal
|
||||
* src/Relationship.py: improve sibling type calculation
|
||||
Issue #1323
|
||||
|
||||
2007-11-22 Benny Malengier <benny.malengier@gramps-project.org>
|
||||
* src/Config/_GrampsConfigKeys.py: key for gen search depth
|
||||
* src/GrampsCfg.py: Gramps preferences allows to set search depth
|
||||
|
@ -546,13 +546,29 @@ class RelationshipCalculator:
|
||||
if fatherother == fatherorig and motherother == motherorig:
|
||||
return self.NORM_SIB
|
||||
elif fatherother == fatherorig or motherother == motherorig:
|
||||
#all birth parents are known, one
|
||||
return self.HALF_SIB
|
||||
else :
|
||||
return self.STEP_SIB
|
||||
else:
|
||||
#other has unknown father or mother,
|
||||
# or orig has unknown father or mother, hence we cannot know
|
||||
# how the siblings are related:
|
||||
# some birth parents are not known, hence we or cannot know if
|
||||
# half siblings. step siblings might be possible, otherwise give up
|
||||
orig_nb_par = self._get_nonbirth_parent_list(db, orig)
|
||||
if fatherother and fatherother in orig_nb_par:
|
||||
#the birth parent of other is non-birth of orig
|
||||
return self.STEP_SIB
|
||||
if motherother and motherother in orig_nb_par:
|
||||
#the birth parent of other is non-birth of orig
|
||||
return self.STEP_SIB
|
||||
other_nb_par = self._get_nonbirth_parent_list(db, other)
|
||||
if fatherorig and fatherorig in other_nb_par:
|
||||
#the one birth parent of other is non-birth of orig
|
||||
return self.STEP_SIB
|
||||
if motherorig and motherorig in other_nb_par:
|
||||
#the one birth parent of other is non-birth of orig
|
||||
return self.STEP_SIB
|
||||
#there is an unknown birth parent, it could be that this is the
|
||||
# birth parent of the other person
|
||||
return self.UNKNOWN_SIB
|
||||
|
||||
def get_parents(self, level):
|
||||
@ -568,8 +584,8 @@ class RelationshipCalculator:
|
||||
"""
|
||||
birthfather = None
|
||||
birthmother = None
|
||||
for f in person.get_parent_family_handle_list():
|
||||
family = db.get_family_from_handle(f)
|
||||
for fam in person.get_parent_family_handle_list():
|
||||
family = db.get_family_from_handle(fam)
|
||||
childrel = [(ref.get_mother_relation(),
|
||||
ref.get_father_relation()) for ref in
|
||||
family.get_child_ref_list()
|
||||
@ -582,6 +598,28 @@ class RelationshipCalculator:
|
||||
break
|
||||
return (birthmother, birthfather)
|
||||
|
||||
def _get_nonbirth_parent_list(self, db, person):
|
||||
""" returns a list of handles of parents of which it is known
|
||||
they are not birth parents.
|
||||
So all parents which do not have relation BIRTH or UNKNOWN
|
||||
are returned.
|
||||
"""
|
||||
nb_parents = []
|
||||
for fam in person.get_parent_family_handle_list():
|
||||
family = db.get_family_from_handle(fam)
|
||||
childrel = [(ref.get_mother_relation(),
|
||||
ref.get_father_relation()) for ref in
|
||||
family.get_child_ref_list()
|
||||
if ref.ref == person.handle]
|
||||
if not childrel[0][0] == gen.lib.ChildRefType.BIRTH \
|
||||
and not childrel[0][0] == gen.lib.ChildRefType.UNKNOWN :
|
||||
nb_parents.append(family.get_mother_handle())
|
||||
if not childrel[0][1] == gen.lib.ChildRefType.BIRTH \
|
||||
and not childrel[0][1] == gen.lib.ChildRefType.UNKNOWN :
|
||||
nb_parents.append(family.get_father_handle())
|
||||
#make every person appear only once:
|
||||
return list(set(nb_parents))
|
||||
|
||||
def get_spouse_type(self, db, orig, other, all_rel = False):
|
||||
""" Translation free determination if orig and other are partners.
|
||||
The procedure returns partner types, these can be passed to
|
||||
|
@ -29,11 +29,9 @@ Display a person's relations to the home person
|
||||
|
||||
from Simple import SimpleAccess, SimpleDoc
|
||||
from gettext import gettext as _
|
||||
from PluginUtils import register_quick_report
|
||||
from PluginUtils import register_quick_report, relationship_class
|
||||
from ReportBase import CATEGORY_QR_PERSON
|
||||
|
||||
from PluginUtils import Tool, relationship_class, register_tool
|
||||
|
||||
# define the formatting string once as a constant. Since this is reused
|
||||
|
||||
_FMT = "%-3d %s"
|
||||
|
@ -24,13 +24,14 @@ Display a person's siblings in a report window
|
||||
"""
|
||||
|
||||
from Simple import SimpleAccess, SimpleDoc
|
||||
from gen.lib import Person
|
||||
from gettext import gettext as _
|
||||
from PluginUtils import register_quick_report
|
||||
from PluginUtils import register_quick_report, relationship_class
|
||||
from ReportBase import CATEGORY_QR_PERSON
|
||||
|
||||
# define the formatting string once as a constant. Since this is reused
|
||||
|
||||
__FMT = "%-30s\t%-10s\t%s"
|
||||
__FMT = "%-30s\t%-10s\t%-18s\t%s"
|
||||
|
||||
def run(database, document, person):
|
||||
"""
|
||||
@ -41,13 +42,24 @@ def run(database, document, person):
|
||||
# setup the simple access functions
|
||||
sdb = SimpleAccess(database)
|
||||
sdoc = SimpleDoc(document)
|
||||
rel_class = relationship_class()
|
||||
rel_str_m = rel_class.get_sibling_relationship_string(
|
||||
rel_class.NORM_SIB, person.get_gender(),
|
||||
Person.MALE)
|
||||
rel_str_f = rel_class.get_sibling_relationship_string(
|
||||
rel_class.NORM_SIB, person.get_gender(),
|
||||
Person.FEMALE)
|
||||
rel_str_u = rel_class.get_sibling_relationship_string(
|
||||
rel_class.NORM_SIB, person.get_gender(),
|
||||
Person.UNKNOWN)
|
||||
|
||||
# display the title
|
||||
sdoc.title(_("Siblings of %s") % sdb.name(person))
|
||||
sdoc.paragraph("")
|
||||
|
||||
# display the header of a table
|
||||
sdoc.header1(__FMT % (_("Sibling"), _("Gender"), _("Birth Date")))
|
||||
sdoc.header1(__FMT % (_("Sibling"), _("Gender"), _("Birth Date"),
|
||||
_("Type")))
|
||||
|
||||
# grab our current id, so we can filter the active person out
|
||||
# of the data
|
||||
@ -62,10 +74,17 @@ def run(database, document, person):
|
||||
|
||||
# only display if this child is not the active person
|
||||
if sdb.gid(child) != gid:
|
||||
rel_str = rel_class.get_sibling_relationship_string(
|
||||
rel_class.get_sibling_type(database, person, child),
|
||||
person.get_gender(), child.get_gender())
|
||||
if rel_str == rel_str_m or rel_str == rel_str_f or \
|
||||
rel_str == rel_str_u :
|
||||
rel_str = ''
|
||||
sdoc.paragraph(__FMT % (
|
||||
sdb.name(child),
|
||||
sdb.gender(child),
|
||||
sdb.birth_date(child)))
|
||||
sdb.birth_date(child),
|
||||
rel_str))
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user