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 1
|
||||||
return 0
|
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
|
# IsAncestorOf
|
||||||
@ -643,7 +680,8 @@ tasks = {
|
|||||||
_("Has the relationships") : HasRelationship,
|
_("Has the relationships") : HasRelationship,
|
||||||
_("Has the death") : HasDeath,
|
_("Has the death") : HasDeath,
|
||||||
_("Has the birth") : HasBirth,
|
_("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 an ancestor of") : IsAncestorOf,
|
||||||
_("Is a female") : IsFemale,
|
_("Is a female") : IsFemale,
|
||||||
_("Is a male") : IsMale,
|
_("Is a male") : IsMale,
|
||||||
|
@ -809,14 +809,18 @@ class WebReportDialog(ReportDialog):
|
|||||||
all.add_rule(GenericFilter.Everyone([]))
|
all.add_rule(GenericFilter.Everyone([]))
|
||||||
|
|
||||||
des = GenericFilter.GenericFilter()
|
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()]))
|
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 = GenericFilter.GenericFilter()
|
||||||
ans.set_name(_("Ancestors of %s") % name)
|
ans.set_name(_("Ancestors of %s") % name)
|
||||||
ans.add_rule(GenericFilter.IsAncestorOf([self.person.getId()]))
|
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 Utils
|
||||||
import intl
|
import intl
|
||||||
import Date
|
import Date
|
||||||
|
import re
|
||||||
|
|
||||||
_ = intl.gettext
|
_ = intl.gettext
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
@ -63,6 +65,14 @@ _calmap = {
|
|||||||
Date.JULIAN : (_month, '@#JULIAN@'),
|
Date.JULIAN : (_month, '@#JULIAN@'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
get_int = re.compile('([0-9]+)')
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@ -486,7 +496,7 @@ class GedcomWriter:
|
|||||||
for family in self.flist:
|
for family in self.flist:
|
||||||
father_alive = mother_alive = 0
|
father_alive = mother_alive = 0
|
||||||
self.g.write("0 @%s@ FAM\n" % self.fid(family.getId()))
|
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()
|
person = family.getFather()
|
||||||
if person != None and person in self.plist:
|
if person != None and person in self.plist:
|
||||||
self.g.write("1 HUSB @%s@\n" % self.pid(person.getId()))
|
self.g.write("1 HUSB @%s@\n" % self.pid(person.getId()))
|
||||||
@ -570,7 +580,7 @@ class GedcomWriter:
|
|||||||
|
|
||||||
def write_person(self,person):
|
def write_person(self,person):
|
||||||
self.g.write("0 @%s@ INDI\n" % self.pid(person.getId()))
|
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())
|
self.write_person_name(person.getPrimaryName(),person.getNickName())
|
||||||
|
|
||||||
if self.altname == ALT_NAME_STD:
|
if self.altname == ALT_NAME_STD:
|
||||||
@ -906,22 +916,20 @@ class GedcomWriter:
|
|||||||
self.write_long_text("NOTE",level+1,ref.getComments())
|
self.write_long_text("NOTE",level+1,ref.getComments())
|
||||||
|
|
||||||
def fid(self,id):
|
def fid(self,id):
|
||||||
if self.fidmap.has_key(id):
|
return id
|
||||||
return self.fidmap[id]
|
|
||||||
else:
|
def prefn(self,person):
|
||||||
val = "F%05d" % self.fidval
|
match = get_int.search(person.getId())
|
||||||
self.fidval = self.fidval + 1
|
if match:
|
||||||
self.fidmap[id] = val
|
self.g.write('1 REFN %d\n' % int(match.groups()[0]))
|
||||||
return val
|
|
||||||
|
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):
|
def pid(self,id):
|
||||||
if self.pidmap.has_key(id):
|
return id
|
||||||
return self.pidmap[id]
|
|
||||||
else:
|
|
||||||
val = "I%05d" % self.pidval
|
|
||||||
self.pidval = self.pidval + 1
|
|
||||||
self.pidmap[id] = val
|
|
||||||
return val
|
|
||||||
|
|
||||||
def sid(self,id):
|
def sid(self,id):
|
||||||
if self.sidmap.has_key(id):
|
if self.sidmap.has_key(id):
|
||||||
|
Loading…
Reference in New Issue
Block a user