Fixed REFN generation, Added decendants/spouses filter
svn: r983
This commit is contained in:
parent
9b66ef0721
commit
162fd30494
@ -183,6 +183,43 @@ class IsDescendantOf(Rule):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# IsDescendantFamilyOf
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class IsDescendantFamilyOf(Rule):
|
||||
"""Rule that checks for a person that is a descendant or the spouse
|
||||
of a descendant of a specified person"""
|
||||
|
||||
labels = [ _('ID') ]
|
||||
|
||||
def name(self):
|
||||
return "Is a descendant family member of"
|
||||
|
||||
def apply(self,p):
|
||||
return self.search(p)
|
||||
|
||||
def search(self,p):
|
||||
if p.getId() == self.list[0]:
|
||||
return 1
|
||||
for (f,r1,r2) in p.getParentList():
|
||||
for p1 in [f.getMother(),f.getFather()]:
|
||||
if p1:
|
||||
if self.search(p1):
|
||||
return 1
|
||||
for fm in p.getFamilyList():
|
||||
if p == fm.getFather():
|
||||
s = fm.getMother()
|
||||
else:
|
||||
s = fm.getFather()
|
||||
for (f,r1,r2) in s.getParentList():
|
||||
for p1 in [f.getMother(),f.getFather()]:
|
||||
if p1:
|
||||
if self.search(p1):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# IsAncestorOf
|
||||
@ -643,7 +680,8 @@ tasks = {
|
||||
_("Has the relationships") : HasRelationship,
|
||||
_("Has the death") : HasDeath,
|
||||
_("Has the birth") : HasBirth,
|
||||
_("Is the descendant of") : IsDescendantOf,
|
||||
_("Is a descendant of") : IsDescendantOf,
|
||||
_("Is a descendant family member of"): IsDescendantFamilyOf,
|
||||
_("Is an ancestor of") : IsAncestorOf,
|
||||
_("Is a female") : IsFemale,
|
||||
_("Is a male") : IsMale,
|
||||
|
@ -809,14 +809,18 @@ class WebReportDialog(ReportDialog):
|
||||
all.add_rule(GenericFilter.Everyone([]))
|
||||
|
||||
des = GenericFilter.GenericFilter()
|
||||
des.set_name(_("Descendants of %s") % name)
|
||||
des.set_name(_("Direct Descendants of %s") % name)
|
||||
des.add_rule(GenericFilter.IsDescendantOf([self.person.getId()]))
|
||||
|
||||
df = GenericFilter.GenericFilter()
|
||||
df.set_name(_("Descendant Families of %s") % name)
|
||||
df.add_rule(GenericFilter.IsDescendantFamilyOf([self.person.getId()]))
|
||||
|
||||
ans = GenericFilter.GenericFilter()
|
||||
ans.set_name(_("Ancestors of %s") % name)
|
||||
ans.add_rule(GenericFilter.IsAncestorOf([self.person.getId()]))
|
||||
|
||||
return [all,des,ans]
|
||||
return [all,des,df,ans]
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -29,6 +29,8 @@ import const
|
||||
import Utils
|
||||
import intl
|
||||
import Date
|
||||
import re
|
||||
|
||||
_ = intl.gettext
|
||||
|
||||
import gtk
|
||||
@ -63,6 +65,14 @@ _calmap = {
|
||||
Date.JULIAN : (_month, '@#JULIAN@'),
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
get_int = re.compile('([0-9]+)')
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
@ -486,7 +496,7 @@ class GedcomWriter:
|
||||
for family in self.flist:
|
||||
father_alive = mother_alive = 0
|
||||
self.g.write("0 @%s@ FAM\n" % self.fid(family.getId()))
|
||||
self.g.write('1 REFN %s\n' % family.getId())
|
||||
self.prefn(family)
|
||||
person = family.getFather()
|
||||
if person != None and person in self.plist:
|
||||
self.g.write("1 HUSB @%s@\n" % self.pid(person.getId()))
|
||||
@ -570,7 +580,7 @@ class GedcomWriter:
|
||||
|
||||
def write_person(self,person):
|
||||
self.g.write("0 @%s@ INDI\n" % self.pid(person.getId()))
|
||||
self.g.write('1 REFN %s\n' % person.getId())
|
||||
self.prefn(person)
|
||||
self.write_person_name(person.getPrimaryName(),person.getNickName())
|
||||
|
||||
if self.altname == ALT_NAME_STD:
|
||||
@ -906,22 +916,20 @@ class GedcomWriter:
|
||||
self.write_long_text("NOTE",level+1,ref.getComments())
|
||||
|
||||
def fid(self,id):
|
||||
if self.fidmap.has_key(id):
|
||||
return self.fidmap[id]
|
||||
else:
|
||||
val = "F%05d" % self.fidval
|
||||
self.fidval = self.fidval + 1
|
||||
self.fidmap[id] = val
|
||||
return val
|
||||
return id
|
||||
|
||||
def prefn(self,person):
|
||||
match = get_int.search(person.getId())
|
||||
if match:
|
||||
self.g.write('1 REFN %d\n' % int(match.groups()[0]))
|
||||
|
||||
def frefn(self,family):
|
||||
match = get_int.search(family.getId())
|
||||
if match:
|
||||
self.g.write('1 REFN %d\n' % int(match.groups()[0]))
|
||||
|
||||
def pid(self,id):
|
||||
if self.pidmap.has_key(id):
|
||||
return self.pidmap[id]
|
||||
else:
|
||||
val = "I%05d" % self.pidval
|
||||
self.pidval = self.pidval + 1
|
||||
self.pidmap[id] = val
|
||||
return val
|
||||
return id
|
||||
|
||||
def sid(self,id):
|
||||
if self.sidmap.has_key(id):
|
||||
|
Loading…
Reference in New Issue
Block a user