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>
|
||||
* src/Relationship.py: internationalization of a string
|
||||
|
||||
|
@ -750,17 +750,20 @@ class RelationshipCalculator:
|
||||
self.__apply_filter_new(db, mother,
|
||||
rel_str + addstr, rel_fam_new,
|
||||
pmap, depth, stoprecursemap, store_all)
|
||||
if not fhandle and not mhandle :
|
||||
#family without parents, add brothers
|
||||
if not fhandle and not mhandle and stoprecursemap is None:
|
||||
#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()
|
||||
if ref.ref != person.handle]
|
||||
addstr = self.REL_SIBLING
|
||||
if pmap.has_key(person.handle) :
|
||||
pmap[person.handle][0] += [rel_str + addstr]
|
||||
pmap[person.handle][1] += [rel_fam_new]
|
||||
#person is already a grandparent in another branch
|
||||
elif store_all or commonancestor:
|
||||
pmap[person.handle] = [[rel_str+addstr],[rel_fam_new]]
|
||||
for chandle in child_list :
|
||||
if pmap.has_key(chandle) :
|
||||
pmap[chandle][0] += [rel_str + addstr]
|
||||
pmap[chandle][1] += [rel_fam_new]
|
||||
#person is already a grandparent in another branch
|
||||
else:
|
||||
pmap[chandle] = [[rel_str+addstr],[rel_fam_new]]
|
||||
fam += 1
|
||||
except:
|
||||
import traceback
|
||||
|
@ -37,9 +37,10 @@ import RelLib
|
||||
|
||||
# define the formatting string once as a constant. Since this is reused
|
||||
|
||||
__FMT = "%-3d %s"
|
||||
__FMT_DET1 ="%-3s %-15s"
|
||||
__FMT_DET2 ="%-30s %-15s\t%-10s %-2s"
|
||||
__FMT = "%-3d %s"
|
||||
__FMT_VOID = " %s"
|
||||
__FMT_DET1 = "%-3s %-15s"
|
||||
__FMT_DET2 = "%-30s %-15s\t%-10s %-2s"
|
||||
|
||||
|
||||
def run(database, document, person):
|
||||
@ -59,10 +60,16 @@ def run(database, document, person):
|
||||
return
|
||||
|
||||
#print title
|
||||
sdoc.title(_("Relationships of %s to %s") % (sdb.name(person) ,
|
||||
sdb.name(home_person)))
|
||||
p2 = sdb.name(home_person)
|
||||
p1 = sdb.name(person)
|
||||
sdoc.title(_("Relationships of %s to %s") % (p1 ,p2))
|
||||
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
|
||||
common, msg_list = rel_class.get_relationship_distance_new(
|
||||
database, person, home_person,
|
||||
@ -74,18 +81,88 @@ def run(database, document, person):
|
||||
#check if not a family too:
|
||||
is_spouse = rel_class.is_spouse(database,person,home_person)
|
||||
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
|
||||
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 :
|
||||
rel_str = _("Not related.")
|
||||
remarks(msg_list,sdoc)
|
||||
return
|
||||
|
||||
count = 1
|
||||
for relation in common:
|
||||
rel_str = rel_class.get_single_relationship_string(len(relation[4]),
|
||||
len(relation[2]),person.get_gender())
|
||||
count = 1
|
||||
|
||||
#collapse common so parents of same fam in common are one line
|
||||
commonnew = []
|
||||
existing_path = []
|
||||
for relation in common:
|
||||
relstrfirst = None
|
||||
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))
|
||||
count += 1
|
||||
|
||||
@ -98,21 +175,26 @@ def run(database, document, person):
|
||||
sdoc.header2(__FMT_DET2 % (' ', _('Parent'), _('Birth'), _('Family')))
|
||||
sdoc.paragraph("")
|
||||
count = 1
|
||||
for relation in common:
|
||||
for relation in commonnew:
|
||||
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))
|
||||
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 \
|
||||
or rel == rel_class.REL_MOTHER_NOTBIRTH:
|
||||
par_str = _('Mother')
|
||||
if rel == rel_class.REL_FATHER \
|
||||
or rel == rel_class.REL_FATHER_NOTBIRTH:
|
||||
par_str = _('Father')
|
||||
if rel == 'p' or rel == 'P':
|
||||
par_str = _('Parents')
|
||||
birth_str = _('Yes')
|
||||
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')
|
||||
sdoc.paragraph(__FMT_DET2 % (' ', par_str, birth_str, str(fam+1)))
|
||||
counter=''
|
||||
@ -126,9 +208,12 @@ def run(database, document, person):
|
||||
sdoc.header2(__FMT_DET2 % (' ', _('Parent'), _('Birth'), _('Family')))
|
||||
sdoc.paragraph("")
|
||||
count = 1
|
||||
for relation in common:
|
||||
for relation in commonnew:
|
||||
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))
|
||||
for rel,fam in zip(relation[4],relation[5]) :
|
||||
par_str = _('Unknown')
|
||||
@ -138,9 +223,11 @@ def run(database, document, person):
|
||||
if rel == rel_class.REL_FATHER \
|
||||
or rel == rel_class.REL_FATHER_NOTBIRTH:
|
||||
par_str = _('Father')
|
||||
if rel == 'p' or rel == 'P':
|
||||
par_str = _('Parents')
|
||||
birth_str = _('Yes')
|
||||
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')
|
||||
sdoc.paragraph(__FMT_DET2 % (' ', par_str, birth_str, str(fam+1)))
|
||||
counter=''
|
||||
|
Loading…
Reference in New Issue
Block a user