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:
Benny Malengier 2007-11-23 08:27:11 +00:00
parent ebc943ed08
commit 36ac2f8190
4 changed files with 73 additions and 12 deletions

View File

@ -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> 2007-11-22 Benny Malengier <benny.malengier@gramps-project.org>
* src/Config/_GrampsConfigKeys.py: key for gen search depth * src/Config/_GrampsConfigKeys.py: key for gen search depth
* src/GrampsCfg.py: Gramps preferences allows to set search depth * src/GrampsCfg.py: Gramps preferences allows to set search depth

View File

@ -546,13 +546,29 @@ class RelationshipCalculator:
if fatherother == fatherorig and motherother == motherorig: if fatherother == fatherorig and motherother == motherorig:
return self.NORM_SIB return self.NORM_SIB
elif fatherother == fatherorig or motherother == motherorig: elif fatherother == fatherorig or motherother == motherorig:
#all birth parents are known, one
return self.HALF_SIB return self.HALF_SIB
else : else :
return self.STEP_SIB return self.STEP_SIB
else: else:
#other has unknown father or mother, # some birth parents are not known, hence we or cannot know if
# or orig has unknown father or mother, hence we cannot know # half siblings. step siblings might be possible, otherwise give up
# how the siblings are related: 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 return self.UNKNOWN_SIB
def get_parents(self, level): def get_parents(self, level):
@ -568,8 +584,8 @@ class RelationshipCalculator:
""" """
birthfather = None birthfather = None
birthmother = None birthmother = None
for f in person.get_parent_family_handle_list(): for fam in person.get_parent_family_handle_list():
family = db.get_family_from_handle(f) family = db.get_family_from_handle(fam)
childrel = [(ref.get_mother_relation(), childrel = [(ref.get_mother_relation(),
ref.get_father_relation()) for ref in ref.get_father_relation()) for ref in
family.get_child_ref_list() family.get_child_ref_list()
@ -582,6 +598,28 @@ class RelationshipCalculator:
break break
return (birthmother, birthfather) 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): def get_spouse_type(self, db, orig, other, all_rel = False):
""" Translation free determination if orig and other are partners. """ Translation free determination if orig and other are partners.
The procedure returns partner types, these can be passed to The procedure returns partner types, these can be passed to

View File

@ -29,11 +29,9 @@ Display a person's relations to the home person
from Simple import SimpleAccess, SimpleDoc from Simple import SimpleAccess, SimpleDoc
from gettext import gettext as _ 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 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 # define the formatting string once as a constant. Since this is reused
_FMT = "%-3d %s" _FMT = "%-3d %s"

View File

@ -24,13 +24,14 @@ Display a person's siblings in a report window
""" """
from Simple import SimpleAccess, SimpleDoc from Simple import SimpleAccess, SimpleDoc
from gen.lib import Person
from gettext import gettext as _ 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 ReportBase import CATEGORY_QR_PERSON
# define the formatting string once as a constant. Since this is reused # 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): def run(database, document, person):
""" """
@ -41,13 +42,24 @@ def run(database, document, person):
# setup the simple access functions # setup the simple access functions
sdb = SimpleAccess(database) sdb = SimpleAccess(database)
sdoc = SimpleDoc(document) 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 # display the title
sdoc.title(_("Siblings of %s") % sdb.name(person)) sdoc.title(_("Siblings of %s") % sdb.name(person))
sdoc.paragraph("") sdoc.paragraph("")
# display the header of a table # 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 # grab our current id, so we can filter the active person out
# of the data # of the data
@ -62,10 +74,17 @@ def run(database, document, person):
# only display if this child is not the active person # only display if this child is not the active person
if sdb.gid(child) != gid: 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 % ( sdoc.paragraph(__FMT % (
sdb.name(child), sdb.name(child),
sdb.gender(child), sdb.gender(child),
sdb.birth_date(child))) sdb.birth_date(child),
rel_str))
#------------------------------------------------------------------------ #------------------------------------------------------------------------
# #