2007-10-24 Benny Malengier <benny.malengier@gramps-project.org>
* src/plugins/all_relations.py: collapse parents same family in one line * src/Relationship.py: change no parent family code svn: r9240
This commit is contained in:
parent
1b70943814
commit
b3d15e1dca
@ -1,3 +1,7 @@
|
|||||||
|
2007-10-24 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
|
* src/plugins/all_relations.py: collapse parents same family in one line
|
||||||
|
* src/Relationship.py: change no parent family code
|
||||||
|
|
||||||
2007-10-23 Benny Malengier <benny.malengier@gramps-project.org>
|
2007-10-23 Benny Malengier <benny.malengier@gramps-project.org>
|
||||||
* src/Relationship.py: internationalization of a string
|
* src/Relationship.py: internationalization of a string
|
||||||
|
|
||||||
|
@ -750,17 +750,20 @@ class RelationshipCalculator:
|
|||||||
self.__apply_filter_new(db, mother,
|
self.__apply_filter_new(db, mother,
|
||||||
rel_str + addstr, rel_fam_new,
|
rel_str + addstr, rel_fam_new,
|
||||||
pmap, depth, stoprecursemap, store_all)
|
pmap, depth, stoprecursemap, store_all)
|
||||||
if not fhandle and not mhandle :
|
if not fhandle and not mhandle and stoprecursemap is None:
|
||||||
#family without parents, add brothers
|
#family without parents, add brothers for orig person
|
||||||
|
#other person has recusemap, and will stop when seeing
|
||||||
|
#the brother.
|
||||||
child_list = [ref.ref for ref in family.get_child_ref_list()
|
child_list = [ref.ref for ref in family.get_child_ref_list()
|
||||||
if ref.ref != person.handle]
|
if ref.ref != person.handle]
|
||||||
addstr = self.REL_SIBLING
|
addstr = self.REL_SIBLING
|
||||||
if pmap.has_key(person.handle) :
|
for chandle in child_list :
|
||||||
pmap[person.handle][0] += [rel_str + addstr]
|
if pmap.has_key(chandle) :
|
||||||
pmap[person.handle][1] += [rel_fam_new]
|
pmap[chandle][0] += [rel_str + addstr]
|
||||||
|
pmap[chandle][1] += [rel_fam_new]
|
||||||
#person is already a grandparent in another branch
|
#person is already a grandparent in another branch
|
||||||
elif store_all or commonancestor:
|
else:
|
||||||
pmap[person.handle] = [[rel_str+addstr],[rel_fam_new]]
|
pmap[chandle] = [[rel_str+addstr],[rel_fam_new]]
|
||||||
fam += 1
|
fam += 1
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -38,8 +38,9 @@ import RelLib
|
|||||||
# 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"
|
||||||
__FMT_DET1 ="%-3s %-15s"
|
__FMT_VOID = " %s"
|
||||||
__FMT_DET2 ="%-30s %-15s\t%-10s %-2s"
|
__FMT_DET1 = "%-3s %-15s"
|
||||||
|
__FMT_DET2 = "%-30s %-15s\t%-10s %-2s"
|
||||||
|
|
||||||
|
|
||||||
def run(database, document, person):
|
def run(database, document, person):
|
||||||
@ -59,10 +60,16 @@ def run(database, document, person):
|
|||||||
return
|
return
|
||||||
|
|
||||||
#print title
|
#print title
|
||||||
sdoc.title(_("Relationships of %s to %s") % (sdb.name(person) ,
|
p2 = sdb.name(home_person)
|
||||||
sdb.name(home_person)))
|
p1 = sdb.name(person)
|
||||||
|
sdoc.title(_("Relationships of %s to %s") % (p1 ,p2))
|
||||||
sdoc.paragraph("")
|
sdoc.paragraph("")
|
||||||
|
|
||||||
|
if person.handle == home_person.handle :
|
||||||
|
sdoc.paragraph(__FMT_VOID % (_("%s and %s are the same person.") % (
|
||||||
|
p1, p2)) )
|
||||||
|
return
|
||||||
|
|
||||||
#obtain all relationships, assume home person has largest tree
|
#obtain all relationships, assume home person has largest tree
|
||||||
common, msg_list = rel_class.get_relationship_distance_new(
|
common, msg_list = rel_class.get_relationship_distance_new(
|
||||||
database, person, home_person,
|
database, person, home_person,
|
||||||
@ -74,18 +81,88 @@ def run(database, document, person):
|
|||||||
#check if not a family too:
|
#check if not a family too:
|
||||||
is_spouse = rel_class.is_spouse(database,person,home_person)
|
is_spouse = rel_class.is_spouse(database,person,home_person)
|
||||||
if is_spouse:
|
if is_spouse:
|
||||||
msg_list.insert(0,_('Additional relation:')+is_spouse)
|
rel_string = is_spouse
|
||||||
|
rstr = _("%(person)s is the %(relationship)s of %(active_person)s."
|
||||||
|
) % {'person' : p2, 'relationship' : rel_string,
|
||||||
|
'active_person' : p1 }
|
||||||
|
sdoc.paragraph(__FMT_VOID % (rstr))
|
||||||
|
sdoc.paragraph("")
|
||||||
|
|
||||||
#all relations
|
#all relations
|
||||||
|
if (not common or common[0][0]== -1 ) and not is_spouse:
|
||||||
|
rstr = _("%(person)s and %(active_person)s are not related.") % {
|
||||||
|
'person' : p2, 'active_person' : p1 }
|
||||||
|
sdoc.paragraph(__FMT_VOID % (rstr))
|
||||||
|
sdoc.paragraph("")
|
||||||
|
|
||||||
if not common or common[0][0]== -1 :
|
if not common or common[0][0]== -1 :
|
||||||
rel_str = _("Not related.")
|
|
||||||
remarks(msg_list,sdoc)
|
remarks(msg_list,sdoc)
|
||||||
return
|
return
|
||||||
|
|
||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
|
#collapse common so parents of same fam in common are one line
|
||||||
|
commonnew = []
|
||||||
|
existing_path = []
|
||||||
for relation in common:
|
for relation in common:
|
||||||
rel_str = rel_class.get_single_relationship_string(len(relation[4]),
|
relstrfirst = None
|
||||||
len(relation[2]),person.get_gender())
|
if relation[2] :
|
||||||
|
relstrfirst = relation[2][:-1]
|
||||||
|
relstrsec = None
|
||||||
|
if relation[4] :
|
||||||
|
relstrsec = relation[4][:-1]
|
||||||
|
familypath = (relstrfirst, relstrsec, relation[3], relation[5])
|
||||||
|
try:
|
||||||
|
posfam = existing_path.index(familypath)
|
||||||
|
except ValueError:
|
||||||
|
posfam = None
|
||||||
|
#if relstr is '', the ancestor is unique, if posfam None, first time
|
||||||
|
# we see this family path
|
||||||
|
if (posfam is not None and relstrfirst is not None and
|
||||||
|
relstrsec is not None):
|
||||||
|
#we already have a common ancestor of this family, just add the
|
||||||
|
#other
|
||||||
|
tmp = commonnew[posfam]
|
||||||
|
if (relation[2][-1]== rel_class.REL_MOTHER or
|
||||||
|
relation[2][-1] == rel_class.REL_FATHER or
|
||||||
|
tmp[2][-1] == rel_class.REL_MOTHER or
|
||||||
|
tmp[2][-1] == rel_class.REL_FATHER or
|
||||||
|
tmp[2][-1] == rel_class.REL_SIBLING) :
|
||||||
|
#we consider the relation to parents by birth
|
||||||
|
reltofirst = 'p'
|
||||||
|
else:
|
||||||
|
reltofirst = 'P'
|
||||||
|
if (relation[4][-1]== rel_class.REL_MOTHER or
|
||||||
|
relation[4][-1] == rel_class.REL_FATHER or
|
||||||
|
tmp[4][-1] == rel_class.REL_MOTHER or
|
||||||
|
tmp[4][-1] == rel_class.REL_FATHER or
|
||||||
|
tmp[4][-1] == rel_class.REL_SIBLING) :
|
||||||
|
#we consider the relation to parents by birth
|
||||||
|
reltosec = 'p'
|
||||||
|
else:
|
||||||
|
reltosec = 'P'
|
||||||
|
commonnew[posfam] = (tmp[0], tmp[1]+[relation[1]],
|
||||||
|
relation[2][:-1]+reltofirst,
|
||||||
|
tmp[3], relation[4][:-1]+reltosec,
|
||||||
|
tmp[5])
|
||||||
|
else :
|
||||||
|
existing_path.append(familypath)
|
||||||
|
commonnew.append((relation[0], [relation[1]], relation[2],
|
||||||
|
relation[3], relation[4], relation[5] )
|
||||||
|
)
|
||||||
|
|
||||||
|
for relation in commonnew:
|
||||||
|
birth = not (rel_class.REL_MOTHER_NOTBIRTH in relation[2] or
|
||||||
|
rel_class.REL_FATHER_NOTBIRTH in relation[2] or
|
||||||
|
'P' in relation[2] or
|
||||||
|
rel_class.REL_MOTHER_NOTBIRTH in relation[4] or
|
||||||
|
rel_class.REL_FATHER_NOTBIRTH in relation[4] or
|
||||||
|
'P' in relation[4]
|
||||||
|
)
|
||||||
|
rel_str = rel_class.get_single_relationship_string(
|
||||||
|
len(relation[4]), len(relation[2]),
|
||||||
|
home_person.get_gender(), person.get_gender(),
|
||||||
|
only_birth = birth)
|
||||||
sdoc.paragraph(__FMT % (count, rel_str))
|
sdoc.paragraph(__FMT % (count, rel_str))
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
@ -98,21 +175,26 @@ def run(database, document, person):
|
|||||||
sdoc.header2(__FMT_DET2 % (' ', _('Parent'), _('Birth'), _('Family')))
|
sdoc.header2(__FMT_DET2 % (' ', _('Parent'), _('Birth'), _('Family')))
|
||||||
sdoc.paragraph("")
|
sdoc.paragraph("")
|
||||||
count = 1
|
count = 1
|
||||||
for relation in common:
|
for relation in commonnew:
|
||||||
counter = str(count)
|
counter = str(count)
|
||||||
name = sdb.name(database.get_person_from_handle(relation[1]))
|
name = sdb.name(database.get_person_from_handle(relation[1][0]))
|
||||||
|
for handle in relation[1][1:]:
|
||||||
|
name += ' ' + _('and') + ' ' + \
|
||||||
|
sdb.name(database.get_person_from_handle(handle))
|
||||||
sdoc.paragraph(__FMT_DET1 % (counter, name))
|
sdoc.paragraph(__FMT_DET1 % (counter, name))
|
||||||
for rel,fam in zip(relation[2],relation[3]) :
|
for rel,fam in zip(relation[2],relation[3]) :
|
||||||
par_str = _('Unknown')
|
par_str = _('Unknown') #when sibling, parent is unknown
|
||||||
if rel == rel_class.REL_MOTHER \
|
if rel == rel_class.REL_MOTHER \
|
||||||
or rel == rel_class.REL_MOTHER_NOTBIRTH:
|
or rel == rel_class.REL_MOTHER_NOTBIRTH:
|
||||||
par_str = _('Mother')
|
par_str = _('Mother')
|
||||||
if rel == rel_class.REL_FATHER \
|
if rel == rel_class.REL_FATHER \
|
||||||
or rel == rel_class.REL_FATHER_NOTBIRTH:
|
or rel == rel_class.REL_FATHER_NOTBIRTH:
|
||||||
par_str = _('Father')
|
par_str = _('Father')
|
||||||
|
if rel == 'p' or rel == 'P':
|
||||||
|
par_str = _('Parents')
|
||||||
birth_str = _('Yes')
|
birth_str = _('Yes')
|
||||||
if rel == rel_class.REL_MOTHER_NOTBIRTH \
|
if rel == rel_class.REL_MOTHER_NOTBIRTH \
|
||||||
or rel == rel_class.REL_FATHER_NOTBIRTH:
|
or rel == rel_class.REL_FATHER_NOTBIRTH or rel == 'P':
|
||||||
birth_str = _('No')
|
birth_str = _('No')
|
||||||
sdoc.paragraph(__FMT_DET2 % (' ', par_str, birth_str, str(fam+1)))
|
sdoc.paragraph(__FMT_DET2 % (' ', par_str, birth_str, str(fam+1)))
|
||||||
counter=''
|
counter=''
|
||||||
@ -126,9 +208,12 @@ def run(database, document, person):
|
|||||||
sdoc.header2(__FMT_DET2 % (' ', _('Parent'), _('Birth'), _('Family')))
|
sdoc.header2(__FMT_DET2 % (' ', _('Parent'), _('Birth'), _('Family')))
|
||||||
sdoc.paragraph("")
|
sdoc.paragraph("")
|
||||||
count = 1
|
count = 1
|
||||||
for relation in common:
|
for relation in commonnew:
|
||||||
counter = str(count)
|
counter = str(count)
|
||||||
name = sdb.name(database.get_person_from_handle(relation[1]))
|
name = sdb.name(database.get_person_from_handle(relation[1][0]))
|
||||||
|
for handle in relation[1][1:]:
|
||||||
|
name += ' ' + _('and') + ' ' + \
|
||||||
|
sdb.name(database.get_person_from_handle(handle))
|
||||||
sdoc.paragraph(__FMT_DET1 % (counter, name))
|
sdoc.paragraph(__FMT_DET1 % (counter, name))
|
||||||
for rel,fam in zip(relation[4],relation[5]) :
|
for rel,fam in zip(relation[4],relation[5]) :
|
||||||
par_str = _('Unknown')
|
par_str = _('Unknown')
|
||||||
@ -138,9 +223,11 @@ def run(database, document, person):
|
|||||||
if rel == rel_class.REL_FATHER \
|
if rel == rel_class.REL_FATHER \
|
||||||
or rel == rel_class.REL_FATHER_NOTBIRTH:
|
or rel == rel_class.REL_FATHER_NOTBIRTH:
|
||||||
par_str = _('Father')
|
par_str = _('Father')
|
||||||
|
if rel == 'p' or rel == 'P':
|
||||||
|
par_str = _('Parents')
|
||||||
birth_str = _('Yes')
|
birth_str = _('Yes')
|
||||||
if rel == rel_class.REL_MOTHER_NOTBIRTH \
|
if rel == rel_class.REL_MOTHER_NOTBIRTH \
|
||||||
or rel == rel_class.REL_FATHER_NOTBIRTH:
|
or rel == rel_class.REL_FATHER_NOTBIRTH or rel == 'P':
|
||||||
birth_str = _('No')
|
birth_str = _('No')
|
||||||
sdoc.paragraph(__FMT_DET2 % (' ', par_str, birth_str, str(fam+1)))
|
sdoc.paragraph(__FMT_DET2 % (' ', par_str, birth_str, str(fam+1)))
|
||||||
counter=''
|
counter=''
|
||||||
|
Loading…
Reference in New Issue
Block a user