* src/GenericFilter.py: Convert to ids.
* src/plugins/FilterEditor.py: Convert to ids. * src/plugins/WebPage.py: Convert to ids. svn: r3002
This commit is contained in:
parent
64ce8b09ea
commit
d2a9753e1c
@ -3,6 +3,10 @@
|
|||||||
Switch from list of 2^gen strings to a dict with only used entries.
|
Switch from list of 2^gen strings to a dict with only used entries.
|
||||||
Clean up generation SpinButton in the dialog.
|
Clean up generation SpinButton in the dialog.
|
||||||
|
|
||||||
|
* src/GenericFilter.py: Convert to ids.
|
||||||
|
* src/plugins/FilterEditor.py: Convert to ids.
|
||||||
|
* src/plugins/WebPage.py: Convert to ids.
|
||||||
|
|
||||||
2004-03-10 Leonid Mamtchenkov <leonid@leonid.maks.net>
|
2004-03-10 Leonid Mamtchenkov <leonid@leonid.maks.net>
|
||||||
* src/plugins/WebPage.py: Link main photo to the original.
|
* src/plugins/WebPage.py: Link main photo to the original.
|
||||||
Use alt strings. Mini tree for many generations.
|
Use alt strings. Mini tree for many generations.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2002-2003 Donald N. Allingham
|
# Copyright (C) 2002-2004 Donald N. Allingham
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -135,7 +135,7 @@ class Everyone(Rule):
|
|||||||
def description(self):
|
def description(self):
|
||||||
return _('Matches everyone in the database')
|
return _('Matches everyone in the database')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -164,13 +164,17 @@ class RelationshipPathBetween(Rule):
|
|||||||
return _("Matches the ancestors of two people back to a common ancestor, producing "
|
return _("Matches the ancestors of two people back to a common ancestor, producing "
|
||||||
"the relationship path between two people.")
|
"the relationship path between two people.")
|
||||||
|
|
||||||
def desc_list(self, p, map, first):
|
def desc_list(self, p_id, map, first):
|
||||||
if not first:
|
if not first:
|
||||||
map[p.get_id()] = 1
|
map[p_id] = 1
|
||||||
|
|
||||||
for fam in p.get_family_id_list():
|
p = self.db.find_person_from_id(p_id)
|
||||||
for child in fam.get_child_id_list():
|
for fam_id in p.get_family_id_list():
|
||||||
self.desc_list(child,map,0)
|
if fam_id:
|
||||||
|
fam = self.db.find_family_from_id(fam_id)
|
||||||
|
for child_id in fam.get_child_id_list():
|
||||||
|
if child_id:
|
||||||
|
self.desc_list(child_id,map,0)
|
||||||
|
|
||||||
def apply_filter(self,rank,person,plist,pmap):
|
def apply_filter(self,rank,person,plist,pmap):
|
||||||
if person == None:
|
if person == None:
|
||||||
@ -183,15 +187,16 @@ class RelationshipPathBetween(Rule):
|
|||||||
self.apply_filter(rank+1,family.get_father_id(),plist,pmap)
|
self.apply_filter(rank+1,family.get_father_id(),plist,pmap)
|
||||||
self.apply_filter(rank+1,family.get_mother_id(),plist,pmap)
|
self.apply_filter(rank+1,family.get_mother_id(),plist,pmap)
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
|
self.db = db
|
||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
root1 = db.get_person(self.list[0])
|
root1 = self.list[0]
|
||||||
root2 = db.get_person(self.list[1])
|
root2 = self.list[1]
|
||||||
self.init_list(root1,root2)
|
self.init_list(root1,root2)
|
||||||
return self.map.has_key(p.get_id())
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
def init_list(self,p1,p2):
|
def init_list(self,p1_id,p2_id):
|
||||||
|
|
||||||
firstMap = {}
|
firstMap = {}
|
||||||
firstList = []
|
firstList = []
|
||||||
@ -200,24 +205,24 @@ class RelationshipPathBetween(Rule):
|
|||||||
common = []
|
common = []
|
||||||
rank = 9999999
|
rank = 9999999
|
||||||
|
|
||||||
self.apply_filter(0,p1,firstList,firstMap)
|
self.apply_filter(0,p1_id,firstList,firstMap)
|
||||||
self.apply_filter(0,p2,secondList,secondMap)
|
self.apply_filter(0,p2_id,secondList,secondMap)
|
||||||
|
|
||||||
for person in firstList:
|
for person_id in firstList:
|
||||||
if person in secondList:
|
if person_id in secondList:
|
||||||
new_rank = firstMap[person.get_id()]
|
new_rank = firstMap[person_id]
|
||||||
if new_rank < rank:
|
if new_rank < rank:
|
||||||
rank = new_rank
|
rank = new_rank
|
||||||
common = [ person ]
|
common = [ person_id ]
|
||||||
elif new_rank == rank:
|
elif new_rank == rank:
|
||||||
common.append(person)
|
common.append(person_id)
|
||||||
|
|
||||||
path1 = { p1.get_id() : 1}
|
path1 = { p1_id : 1}
|
||||||
path2 = { p2.get_id() : 1}
|
path2 = { p2_id : 1}
|
||||||
|
|
||||||
for person in common:
|
for person_id in common:
|
||||||
new_map = {}
|
new_map = {}
|
||||||
self.desc_list(person,new_map,1)
|
self.desc_list(person_id,new_map,1)
|
||||||
self.get_intersection(path1,firstMap,new_map)
|
self.get_intersection(path1,firstMap,new_map)
|
||||||
self.get_intersection(path2,secondMap,new_map)
|
self.get_intersection(path2,secondMap,new_map)
|
||||||
|
|
||||||
@ -226,7 +231,7 @@ class RelationshipPathBetween(Rule):
|
|||||||
for e in path2:
|
for e in path2:
|
||||||
self.map[e] = 1
|
self.map[e] = 1
|
||||||
for e in common:
|
for e in common:
|
||||||
self.map[e.get_id()] = 1
|
self.map[e] = 1
|
||||||
|
|
||||||
def get_intersection(self,target, map1, map2):
|
def get_intersection(self,target, map1, map2):
|
||||||
for e in map1.keys():
|
for e in map1.keys():
|
||||||
@ -252,8 +257,8 @@ class HasIdOf(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _('General filters')
|
return _('General filters')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
return p.get_id() == self.list[0]
|
return p_id == self.list[0]
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -274,8 +279,8 @@ class HasCompleteRecord(Rule):
|
|||||||
def description(self):
|
def description(self):
|
||||||
return _('Matches all people whose records are complete')
|
return _('Matches all people whose records are complete')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
return p.get_complete() == 1
|
return db.find_person_from_id(p_id).get_complete() == 1
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -297,8 +302,8 @@ class IsFemale(Rule):
|
|||||||
def description(self):
|
def description(self):
|
||||||
return _('Matches all females')
|
return _('Matches all females')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
return p.get_gender() == RelLib.Person.female
|
return db.find_person_from_id(p_id).get_gender() == RelLib.Person.female
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -325,8 +330,9 @@ class IsDescendantOf(Rule):
|
|||||||
def description(self):
|
def description(self):
|
||||||
return _('Matches all descendants for the specified person')
|
return _('Matches all descendants for the specified person')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
self.orig = p
|
self.orig_id = p_id
|
||||||
|
self.db = db
|
||||||
try:
|
try:
|
||||||
if int(self.list[1]):
|
if int(self.list[1]):
|
||||||
first = 0
|
first = 0
|
||||||
@ -337,17 +343,20 @@ class IsDescendantOf(Rule):
|
|||||||
|
|
||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
root = db.get_person(self.list[0])
|
root_id = self.list[0]
|
||||||
self.init_list(root,first)
|
self.init_list(root_id,first)
|
||||||
return self.map.has_key(p.get_id())
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
def init_list(self,p,first):
|
def init_list(self,p_id,first):
|
||||||
if not first:
|
if not first:
|
||||||
self.map[p.get_id()] = 1
|
self.map[p_id] = 1
|
||||||
|
|
||||||
for fam in p.get_family_id_list():
|
p = self.db.find_person_from_id(p_id)
|
||||||
for child in fam.get_child_id_list():
|
for fam_id in p.get_family_id_list():
|
||||||
self.init_list(child,0)
|
if fam_id:
|
||||||
|
fam = self.db.find_family_from_id(fam_id)
|
||||||
|
for child_id in fam.get_child_id_list():
|
||||||
|
self.init_list(child_id,0)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -372,8 +381,9 @@ class IsDescendantOfFilterMatch(IsDescendantOf):
|
|||||||
def description(self):
|
def description(self):
|
||||||
return _("Matches people that are descendants of someone matched by a filter")
|
return _("Matches people that are descendants of someone matched by a filter")
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
self.orig = p
|
self.orig_id = p_id
|
||||||
|
self.db = db
|
||||||
try:
|
try:
|
||||||
if int(self.list[1]):
|
if int(self.list[1]):
|
||||||
first = 0
|
first = 0
|
||||||
@ -385,10 +395,10 @@ class IsDescendantOfFilterMatch(IsDescendantOf):
|
|||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
filter = MatchesFilter(self.list)
|
filter = MatchesFilter(self.list)
|
||||||
for person in db.get_person_id_map ().values ():
|
for person_id in db.get_person_keys():
|
||||||
if filter.apply (db, person):
|
if filter.apply (db, person_id):
|
||||||
self.init_list (person, first)
|
self.init_list (person_id, first)
|
||||||
return self.map.has_key(p.get_id())
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -416,24 +426,27 @@ class IsLessThanNthGenerationDescendantOf(Rule):
|
|||||||
return _("Matches people that are descendants of a specified person "
|
return _("Matches people that are descendants of a specified person "
|
||||||
"not more than N generations away")
|
"not more than N generations away")
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
self.orig = p
|
self.orig_id = p_id
|
||||||
|
self.db = db
|
||||||
|
|
||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
root = db.get_person(self.list[0])
|
root_id = self.list[0]
|
||||||
self.init_list(root,0)
|
self.init_list(root_id,0)
|
||||||
return self.map.has_key(p.get_id())
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
def init_list(self,p,gen):
|
def init_list(self,p_id,gen):
|
||||||
if gen:
|
if gen:
|
||||||
self.map[p.get_id()] = 1
|
self.map[p_id] = 1
|
||||||
if gen >= int(self.list[1]):
|
if gen >= int(self.list[1]):
|
||||||
return
|
return
|
||||||
|
|
||||||
for fam in p.get_family_id_list():
|
p = self.db.find_person_from_id(p_id)
|
||||||
for child in fam.get_child_id_list():
|
for fam_id in p.get_family_id_list():
|
||||||
self.init_list(child,gen+1)
|
fam = self.db.find_family_from_id(fam_id)
|
||||||
|
for child_id in fam.get_child_id_list():
|
||||||
|
self.init_list(child_id,gen+1)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -461,22 +474,25 @@ class IsMoreThanNthGenerationDescendantOf(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _("Descendant filters")
|
return _("Descendant filters")
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
self.orig = p
|
self.orig_id = p_id
|
||||||
|
self.db = db
|
||||||
|
|
||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
root = db.get_person(self.list[0])
|
root_id = self.list[0]
|
||||||
self.init_list(root,0)
|
self.init_list(root_id,0)
|
||||||
return self.map.has_key(p.get_id())
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
def init_list(self,p,gen):
|
def init_list(self,p_id,gen):
|
||||||
if gen >= int(self.list[1]):
|
if gen >= int(self.list[1]):
|
||||||
self.map[p.get_id()] = 1
|
self.map[p_id] = 1
|
||||||
|
|
||||||
for fam in p.get_family_id_list():
|
p = self.db.find_person_from_id(p_id)
|
||||||
for child in fam.get_child_id_list():
|
for fam_id in p.get_family_id_list():
|
||||||
self.init_list(child,gen+1)
|
fam = self.db.find_family_from_id(fam_id)
|
||||||
|
for child_id in fam.get_child_id_list():
|
||||||
|
self.init_list(child_id,gen+1)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -503,21 +519,24 @@ class IsChildOfFilterMatch(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _('Family filters')
|
return _('Family filters')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
self.orig = p
|
self.orig_id = p_id
|
||||||
|
self.db = db
|
||||||
|
|
||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
filter = MatchesFilter(self.list)
|
filter = MatchesFilter(self.list)
|
||||||
for person in db.get_person_id_map ().values ():
|
for person_id in db.get_person_keys():
|
||||||
if filter.apply (db, person):
|
if filter.apply (db, person_id):
|
||||||
self.init_list (person)
|
self.init_list (person_id)
|
||||||
return self.map.has_key(p.get_id())
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
def init_list(self,p):
|
def init_list(self,p_id):
|
||||||
for fam in p.get_family_id_list():
|
p = self.db.find_person_from_id(p_id)
|
||||||
for child in fam.get_child_id_list():
|
for fam_id in p.get_family_id_list():
|
||||||
self.map[child.get_id()] = 1
|
fam = self.db.find_family_from_id(fam_id)
|
||||||
|
for child_id in fam.get_child_id_list():
|
||||||
|
self.map[child_id] = 1
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -540,33 +559,33 @@ class IsDescendantFamilyOf(Rule):
|
|||||||
return _("Matches people that are descendants or the spouse "
|
return _("Matches people that are descendants or the spouse "
|
||||||
"of a descendant of a specified person")
|
"of a descendant of a specified person")
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
self.map = {}
|
self.map = {}
|
||||||
self.orig = p
|
self.orig_id = p_id
|
||||||
self.db = db
|
self.db = db
|
||||||
return self.search(p,1)
|
return self.search(p_id,1)
|
||||||
|
|
||||||
def search(self,p,val):
|
def search(self,p_id,val):
|
||||||
if p.get_id() == self.list[0]:
|
if p_id == self.list[0]:
|
||||||
self.map[p.get_id()] = 1
|
self.map[p_id] = 1
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
p = self.db.find_person_from_id(p_id)
|
||||||
for (f,r1,r2) in p.get_parent_family_id_list():
|
for (f,r1,r2) in p.get_parent_family_id_list():
|
||||||
family = self.db.find_family_from_id(f)
|
family = self.db.find_family_from_id(f)
|
||||||
for person_id in [family.get_mother_id(),family.get_father_id()]:
|
for person_id in [family.get_mother_id(),family.get_father_id()]:
|
||||||
if person_id:
|
if person_id:
|
||||||
person = self.db.find_person_from_id(person_id)
|
if self.search(person_id,0):
|
||||||
if self.search(person,0):
|
|
||||||
return 1
|
return 1
|
||||||
if val:
|
if val:
|
||||||
for family_id in p.get_family_id_list():
|
for family_id in p.get_family_id_list():
|
||||||
family = self.db.find_family_from_id(family_id)
|
family = self.db.find_family_from_id(family_id)
|
||||||
if p == family.get_father_id():
|
if p_id == family.get_father_id():
|
||||||
spouse_id = family.get_mother_id()
|
spouse_id = family.get_mother_id()
|
||||||
else:
|
else:
|
||||||
spouse_id = family.get_father_id()
|
spouse_id = family.get_father_id()
|
||||||
if spouse_id:
|
if spouse_id:
|
||||||
spouse = self.db.find_person_from_id(spouse_id)
|
if self.search(spouse_id,0):
|
||||||
if self.search(spouse,0):
|
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -594,9 +613,10 @@ class IsAncestorOf(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _("Ancestral filters")
|
return _("Ancestral filters")
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
"""Assume that if 'Inclusive' not defined, assume inclusive"""
|
"""Assume that if 'Inclusive' not defined, assume inclusive"""
|
||||||
self.orig = p
|
self.orig_id = p_id
|
||||||
|
self.db = db
|
||||||
try:
|
try:
|
||||||
if int(self.list[1]):
|
if int(self.list[1]):
|
||||||
first = 0
|
first = 0
|
||||||
@ -607,23 +627,25 @@ class IsAncestorOf(Rule):
|
|||||||
|
|
||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
root = db.get_person(self.list[0])
|
root_id = self.list[0]
|
||||||
self.init_ancestor_list(root,first)
|
self.init_ancestor_list(root_id,first)
|
||||||
return self.map.has_key(p.get_id())
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
def init_ancestor_list(self,p,first):
|
def init_ancestor_list(self,p_id,first):
|
||||||
if not first:
|
if not first:
|
||||||
self.map[p.get_id()] = 1
|
self.map[p_id] = 1
|
||||||
|
|
||||||
fam = p.get_main_parents_family_id()
|
p = self.db.find_person_from_id(p_id)
|
||||||
if fam:
|
fam_id = p.get_main_parents_family_id()
|
||||||
f = fam.get_father_id()
|
if fam_id:
|
||||||
m = fam.get_mother_id()
|
fam = self.db.find_family_from_id(fam_id)
|
||||||
|
f_id = fam.get_father_id()
|
||||||
|
m_id = fam.get_mother_id()
|
||||||
|
|
||||||
if f:
|
if f_id:
|
||||||
self.init_ancestor_list(f,0)
|
self.init_ancestor_list(f_id,0)
|
||||||
if m:
|
if m_id:
|
||||||
self.init_ancestor_list(m,0)
|
self.init_ancestor_list(m_id,0)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -649,8 +671,8 @@ class IsAncestorOfFilterMatch(IsAncestorOf):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _("Ancestral filters")
|
return _("Ancestral filters")
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
self.orig = p
|
self.orig_id = p_id
|
||||||
try:
|
try:
|
||||||
if int(self.list[1]):
|
if int(self.list[1]):
|
||||||
first = 0
|
first = 0
|
||||||
@ -662,10 +684,10 @@ class IsAncestorOfFilterMatch(IsAncestorOf):
|
|||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
filter = MatchesFilter(self.list[0])
|
filter = MatchesFilter(self.list[0])
|
||||||
for person in db.get_person_id_map ().values ():
|
for person_id in db.get_person_keys():
|
||||||
if filter.apply (db, person):
|
if filter.apply (db, person_id):
|
||||||
self.init_ancestor_list (person,first)
|
self.init_ancestor_list (person_id,first)
|
||||||
return self.map.has_key(p.get_id())
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -693,31 +715,34 @@ class IsLessThanNthGenerationAncestorOf(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _("Ancestral filters")
|
return _("Ancestral filters")
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
self.orig = p
|
self.orig_id = p_id
|
||||||
|
self.db = db
|
||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
root = db.get_person(self.list[0])
|
root_id = self.list[0]
|
||||||
self.init_ancestor_list(root,0)
|
self.init_ancestor_list(root_id,0)
|
||||||
return self.map.has_key(p.get_id())
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
def init_ancestor_list(self,p,gen):
|
def init_ancestor_list(self,p_id,gen):
|
||||||
# if self.map.has_key(p.get_id()) == 1:
|
# if self.map.has_key(p.get_id()) == 1:
|
||||||
# loop_error(self.orig,p)
|
# loop_error(self.orig,p)
|
||||||
if gen:
|
if gen:
|
||||||
self.map[p.get_id()] = 1
|
self.map[p_id] = 1
|
||||||
if gen >= int(self.list[1]):
|
if gen >= int(self.list[1]):
|
||||||
return
|
return
|
||||||
|
|
||||||
fam = p.get_main_parents_family_id()
|
p = self.db.find_person_from_id(p_id)
|
||||||
if fam:
|
fam_id = p.get_main_parents_family_id()
|
||||||
f = fam.get_father_id()
|
if fam_id:
|
||||||
m = fam.get_mother_id()
|
fam = self.db.find_family_from_id(fam_id)
|
||||||
|
f_id = fam.get_father_id()
|
||||||
|
m_id = fam.get_mother_id()
|
||||||
|
|
||||||
if f:
|
if f_id:
|
||||||
self.init_ancestor_list(f,gen+1)
|
self.init_ancestor_list(f_id,gen+1)
|
||||||
if m:
|
if m_id:
|
||||||
self.init_ancestor_list(m,gen+1)
|
self.init_ancestor_list(m_id,gen+1)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -745,29 +770,32 @@ class IsMoreThanNthGenerationAncestorOf(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _("Ancestral filters")
|
return _("Ancestral filters")
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
self.orig = p
|
self.orig_id = p_id
|
||||||
|
self.db = db
|
||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
root = db.get_person(self.list[0])
|
root_id = self.list[0]
|
||||||
self.init_ancestor_list(root,0)
|
self.init_ancestor_list(root_id,0)
|
||||||
return self.map.has_key(p.get_id())
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
def init_ancestor_list(self,p,gen):
|
def init_ancestor_list(self,p_id,gen):
|
||||||
# if self.map.has_key(p.get_id()) == 1:
|
# if self.map.has_key(p.get_id()) == 1:
|
||||||
# loop_error(self.orig,p)
|
# loop_error(self.orig,p)
|
||||||
if gen >= int(self.list[1]):
|
if gen >= int(self.list[1]):
|
||||||
self.map[p.get_id()] = 1
|
self.map[p_id] = 1
|
||||||
|
|
||||||
fam = p.get_main_parents_family_id()
|
p = self.db.find_person_from_id(p_id)
|
||||||
if fam:
|
fam_id = p.get_main_parents_family_id()
|
||||||
f = fam.get_father_id()
|
if fam_id:
|
||||||
m = fam.get_mother_id()
|
fam = self.db.find_family_from_id(fam_id)
|
||||||
|
f_id = fam.get_father_id()
|
||||||
|
m_id = fam.get_mother_id()
|
||||||
|
|
||||||
if f:
|
if f_id:
|
||||||
self.init_ancestor_list(f,gen+1)
|
self.init_ancestor_list(f_id,gen+1)
|
||||||
if m:
|
if m_id:
|
||||||
self.init_ancestor_list(m,gen+1)
|
self.init_ancestor_list(m_id,gen+1)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -795,21 +823,24 @@ class IsParentOfFilterMatch(Rule):
|
|||||||
return _('Family filters')
|
return _('Family filters')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p):
|
||||||
self.orig = p
|
self.orig_id = p_id
|
||||||
|
self.db = db
|
||||||
|
|
||||||
if not self.init:
|
if not self.init:
|
||||||
self.init = 1
|
self.init = 1
|
||||||
filter = MatchesFilter(self.list)
|
filter = MatchesFilter(self.list)
|
||||||
for person in db.get_person_id_map ().values ():
|
for person_id in db.get_person_keys():
|
||||||
if filter.apply (db, person):
|
if filter.apply (db, person_id):
|
||||||
self.init_list (person)
|
self.init_list (person_id)
|
||||||
return self.map.has_key(p.get_id())
|
return self.map.has_key(p_id)
|
||||||
|
|
||||||
def init_list(self,p):
|
def init_list(self,p_id):
|
||||||
for fam in p.get_main_parents_family_id():
|
p = self.db.find_person_from_id(p_id)
|
||||||
for parent in [fam.get_father_id (), fam.get_mother_id ()]:
|
for fam_id in p.get_main_parents_family_id():
|
||||||
if parent:
|
fam = self.db.find_family_from_id(fam_id)
|
||||||
self.map[parent.get_id()] = 1
|
for parent_id in [fam.get_father_id (), fam.get_mother_id ()]:
|
||||||
|
if parent_id:
|
||||||
|
self.map[parent_id] = 1
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -841,19 +872,19 @@ class HasCommonAncestorWith(Rule):
|
|||||||
|
|
||||||
def init_ancestor_cache(self,db):
|
def init_ancestor_cache(self,db):
|
||||||
# list[0] is an Id, but we need to pass a Person to for_each_ancestor.
|
# list[0] is an Id, but we need to pass a Person to for_each_ancestor.
|
||||||
p = db.get_person(self.list[0])
|
p_id = self.list[0]
|
||||||
if p:
|
if p_id:
|
||||||
def init(self,pid): self.ancestor_cache[pid] = 1
|
def init(self,pid): self.ancestor_cache[pid] = 1
|
||||||
for_each_ancestor([p],init,self)
|
for_each_ancestor([p_id],init,self)
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
# On the first call, we build the ancestor cache for the
|
# On the first call, we build the ancestor cache for the
|
||||||
# reference person. Then, for each person to test,
|
# reference person. Then, for each person to test,
|
||||||
# we browse his ancestors until we found one in the cache.
|
# we browse his ancestors until we found one in the cache.
|
||||||
if len(self.ancestor_cache) == 0:
|
if len(self.ancestor_cache) == 0:
|
||||||
self.init_ancestor_cache(db)
|
self.init_ancestor_cache(db)
|
||||||
return for_each_ancestor([p],
|
return for_each_ancestor([p_id],
|
||||||
lambda self,p: self.ancestor_cache.has_key(p),
|
lambda self,p_id: self.ancestor_cache.has_key(p_id),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -883,10 +914,10 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith):
|
|||||||
def init_ancestor_cache(self,db):
|
def init_ancestor_cache(self,db):
|
||||||
filter = MatchesFilter(self.list)
|
filter = MatchesFilter(self.list)
|
||||||
def init(self,pid): self.ancestor_cache[pid] = 1
|
def init(self,pid): self.ancestor_cache[pid] = 1
|
||||||
for p in db.get_person_id_map ().values ():
|
for p_id in db.get_person_keys():
|
||||||
if (not self.ancestor_cache.has_key (p.get_id ())
|
if (not self.ancestor_cache.has_key (p_id)
|
||||||
and filter.apply (db, p)):
|
and filter.apply (db, p_id)):
|
||||||
for_each_ancestor([p],init,self)
|
for_each_ancestor([p_id],init,self)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -907,8 +938,8 @@ class IsMale(Rule):
|
|||||||
def description(self):
|
def description(self):
|
||||||
return _('Matches all males')
|
return _('Matches all males')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
return p.get_gender() == RelLib.Person.male
|
return self.db.find_person_from_id(p_id).get_gender() == RelLib.Person.male
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -937,8 +968,12 @@ class HasEvent(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _('Event filters')
|
return _('Event filters')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
for event in p.get_event_list():
|
p = db.find_person_from_id(p_id)
|
||||||
|
for event_id in p.get_event_list():
|
||||||
|
if not event_id:
|
||||||
|
continue
|
||||||
|
event = db.find_event_from_id(event_id)
|
||||||
val = 1
|
val = 1
|
||||||
if self.list[0] and event.get_name() != self.list[0]:
|
if self.list[0] and event.get_name() != self.list[0]:
|
||||||
val = 0
|
val = 0
|
||||||
@ -949,11 +984,14 @@ class HasEvent(Rule):
|
|||||||
if date_cmp(self.date,event.get_date_object()):
|
if date_cmp(self.date,event.get_date_object()):
|
||||||
val = 0
|
val = 0
|
||||||
if self.list[2]:
|
if self.list[2]:
|
||||||
pn = event.get_place_name()
|
pl_id = event.get_place_id()
|
||||||
if find(pn.upper(),self.list[2].upper()) == -1:
|
if pl_id:
|
||||||
val = 0
|
pl = db.find_place_from_id(pl_id)
|
||||||
if val == 1:
|
pn = pl.get_title()
|
||||||
return 1
|
if find(pn.upper(),self.list[2].upper()) == -1:
|
||||||
|
val = 0
|
||||||
|
if val == 1:
|
||||||
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -984,9 +1022,14 @@ class HasFamilyEvent(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _('Event filters')
|
return _('Event filters')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
for f in p.get_family_id_list():
|
p = db.find_person_from_id(p_id)
|
||||||
for event in f.get_event_list():
|
for f_id in p.get_family_id_list():
|
||||||
|
f = db.find_family_from_id(f_id)
|
||||||
|
for event_id in f.get_event_list():
|
||||||
|
if not event_id:
|
||||||
|
continue
|
||||||
|
event = db.find_event_from_id(event_id)
|
||||||
val = 1
|
val = 1
|
||||||
if self.list[0] and event.get_name() != self.list[0]:
|
if self.list[0] and event.get_name() != self.list[0]:
|
||||||
val = 0
|
val = 0
|
||||||
@ -996,11 +1039,14 @@ class HasFamilyEvent(Rule):
|
|||||||
if self.date:
|
if self.date:
|
||||||
if date_cmp(self.date,event.get_date_object()):
|
if date_cmp(self.date,event.get_date_object()):
|
||||||
val = 0
|
val = 0
|
||||||
pn = event.get_place_name().upper()
|
pl_id = event.get_place_id()
|
||||||
if self.list[2] and find(pn,self.list[2].upper()) == -1:
|
if pl_id:
|
||||||
val = 0
|
pl = db.find_place_from_id(pl_id)
|
||||||
if val == 1:
|
pn = pl.get_title()
|
||||||
return 1
|
if self.list[2] and find(pn,self.list[2].upper()) == -1:
|
||||||
|
val = 0
|
||||||
|
if val == 1:
|
||||||
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -1024,13 +1070,15 @@ class HasRelationship(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _('Family filters')
|
return _('Family filters')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
rel_type = 0
|
rel_type = 0
|
||||||
cnt = 0
|
cnt = 0
|
||||||
|
p = db.find_person_from_id(p_id)
|
||||||
num_rel = len(p.get_family_id_list())
|
num_rel = len(p.get_family_id_list())
|
||||||
|
|
||||||
# count children and look for a relationship type match
|
# count children and look for a relationship type match
|
||||||
for f in p.get_family_id_list():
|
for f_id in p.get_family_id_list():
|
||||||
|
f = db.find_family_from_id(f_id)
|
||||||
cnt = cnt + len(f.get_child_id_list())
|
cnt = cnt + len(f.get_child_id_list())
|
||||||
if self.list[1] and f.get_relationship() == self.list[1]:
|
if self.list[1] and f.get_relationship() == self.list[1]:
|
||||||
rel_type = 1
|
rel_type = 1
|
||||||
@ -1086,17 +1134,24 @@ class HasBirth(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _('Event filters')
|
return _('Event filters')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
event = p.get_birth()
|
p = db.find_person_from_id(p_id)
|
||||||
|
event_id = p.get_birth_id()
|
||||||
|
if not event_id:
|
||||||
|
return 0
|
||||||
|
event = db.find_event_from_id(event_id)
|
||||||
ed = event.get_description().upper()
|
ed = event.get_description().upper()
|
||||||
if len(self.list) > 2 and find(ed,self.list[2].upper())==-1:
|
if len(self.list) > 2 and find(ed,self.list[2].upper())==-1:
|
||||||
return 0
|
return 0
|
||||||
if self.date:
|
if self.date:
|
||||||
if date_cmp(self.date,event.get_date_object()) == 0:
|
if date_cmp(self.date,event.get_date_object()) == 0:
|
||||||
return 0
|
return 0
|
||||||
pn = event.get_place_name().upper()
|
pl_id = event.get_place_id()
|
||||||
if len(self.list) > 1 and find(pn,self.list[1].upper()) == -1:
|
if pl_id:
|
||||||
return 0
|
pl = db.find_place_from_id(pl_id)
|
||||||
|
pn = pl.get_title()
|
||||||
|
if len(self.list) > 1 and find(pn,self.list[1].upper()) == -1:
|
||||||
|
return 0
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -1126,17 +1181,24 @@ class HasDeath(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _('Event filters')
|
return _('Event filters')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
event = p.get_death()
|
p = db.find_person_from_id(p_id)
|
||||||
|
event_id = p.get_death_id()
|
||||||
|
if not event_id:
|
||||||
|
return 0
|
||||||
|
event = db.find_event_from_id(event_id)
|
||||||
ed = event.get_description().upper()
|
ed = event.get_description().upper()
|
||||||
if self.list[2] and find(ed,self.list[2].upper())==-1:
|
if self.list[2] and find(ed,self.list[2].upper())==-1:
|
||||||
return 0
|
return 0
|
||||||
if self.date:
|
if self.date:
|
||||||
if date_cmp(self.date,event.get_date_object()) == 0:
|
if date_cmp(self.date,event.get_date_object()) == 0:
|
||||||
return 0
|
return 0
|
||||||
pn = event.get_place_name().upper()
|
pl_id = event.get_place_id()
|
||||||
if self.list[1] and find(pn,self.list[1].upper()) == -1:
|
if pl_id:
|
||||||
return 0
|
pl = db.find_place_from_id(pl_id)
|
||||||
|
pn = pl.get_title()
|
||||||
|
if self.list[1] and find(pn,self.list[1].upper()) == -1:
|
||||||
|
return 0
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -1152,7 +1214,8 @@ class HasAttribute(Rule):
|
|||||||
def name(self):
|
def name(self):
|
||||||
return 'Has the personal attribute'
|
return 'Has the personal attribute'
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
|
p = db.find_person_from_id(p_id)
|
||||||
for event in p.getAttributes():
|
for event in p.getAttributes():
|
||||||
if self.list[0] and event.get_type() != self.list[0]:
|
if self.list[0] and event.get_type() != self.list[0]:
|
||||||
return 0
|
return 0
|
||||||
@ -1174,8 +1237,10 @@ class HasFamilyAttribute(Rule):
|
|||||||
def name(self):
|
def name(self):
|
||||||
return 'Has the family attribute'
|
return 'Has the family attribute'
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
for f in p.get_family_id_list():
|
p = db.find_person_from_id(p_id)
|
||||||
|
for f_id in p.get_family_id_list():
|
||||||
|
f = db.find_family_from_id(f_id)
|
||||||
for event in f.getAttributes():
|
for event in f.getAttributes():
|
||||||
val = 1
|
val = 1
|
||||||
if self.list[0] and event.get_type() != self.list[0]:
|
if self.list[0] and event.get_type() != self.list[0]:
|
||||||
@ -1206,11 +1271,12 @@ class HasNameOf(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _('General filters')
|
return _('General filters')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
self.f = self.list[0]
|
self.f = self.list[0]
|
||||||
self.l = self.list[1]
|
self.l = self.list[1]
|
||||||
self.s = self.list[2]
|
self.s = self.list[2]
|
||||||
self.t = self.list[3]
|
self.t = self.list[3]
|
||||||
|
p = db.find_person_from_id(p_id)
|
||||||
for name in [p.get_primary_name()] + p.get_alternate_names():
|
for name in [p.get_primary_name()] + p.get_alternate_names():
|
||||||
val = 1
|
val = 1
|
||||||
if self.f and find(name.get_first_name().upper(),self.f.upper()) == -1:
|
if self.f and find(name.get_first_name().upper(),self.f.upper()) == -1:
|
||||||
@ -1239,13 +1305,13 @@ class MatchesFilter(Rule):
|
|||||||
def name(self):
|
def name(self):
|
||||||
return 'Matches the filter named'
|
return 'Matches the filter named'
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
for filter in SystemFilters.get_filters():
|
for filter in SystemFilters.get_filters():
|
||||||
if filter.get_name() == self.list[0]:
|
if filter.get_name() == self.list[0]:
|
||||||
return filter.check(p)
|
return filter.check(p_id)
|
||||||
for filter in CustomFilters.get_filters():
|
for filter in CustomFilters.get_filters():
|
||||||
if filter.get_name() == self.list[0]:
|
if filter.get_name() == self.list[0]:
|
||||||
return filter.check(db,p)
|
return filter.check(db,p_id)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -1268,15 +1334,17 @@ class IsSpouseOfFilterMatch(Rule):
|
|||||||
def category(self):
|
def category(self):
|
||||||
return _('Family filters')
|
return _('Family filters')
|
||||||
|
|
||||||
def apply(self,db,p):
|
def apply(self,db,p_id):
|
||||||
filter = MatchesFilter (self.list)
|
filter = MatchesFilter (self.list)
|
||||||
for family in p.get_family_id_list ():
|
p = db.find_person_from_id(p_id)
|
||||||
for spouse in [family.get_father_id (), family.get_mother_id ()]:
|
for family_id in p.get_family_id_list ():
|
||||||
if not spouse:
|
family = db.find_family_from_id(family_id)
|
||||||
|
for spouse_id in [family.get_father_id (), family.get_mother_id ()]:
|
||||||
|
if not spouse_id:
|
||||||
continue
|
continue
|
||||||
if spouse == p:
|
if spouse_id == p_id:
|
||||||
continue
|
continue
|
||||||
if filter.apply (db, spouse):
|
if filter.apply (db, spouse_id):
|
||||||
return 1
|
return 1
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@ -1341,10 +1409,10 @@ class GenericFilter:
|
|||||||
def get_rules(self):
|
def get_rules(self):
|
||||||
return self.flist
|
return self.flist
|
||||||
|
|
||||||
def check_or(self,db,p):
|
def check_or(self,db,p_id):
|
||||||
test = 0
|
test = 0
|
||||||
for rule in self.flist:
|
for rule in self.flist:
|
||||||
test = test or rule.apply(db,p)
|
test = test or rule.apply(db,p_id)
|
||||||
if test:
|
if test:
|
||||||
break
|
break
|
||||||
if self.invert:
|
if self.invert:
|
||||||
@ -1352,20 +1420,20 @@ class GenericFilter:
|
|||||||
else:
|
else:
|
||||||
return test
|
return test
|
||||||
|
|
||||||
def check_xor(self,db,p):
|
def check_xor(self,db,p_id):
|
||||||
test = 0
|
test = 0
|
||||||
for rule in self.flist:
|
for rule in self.flist:
|
||||||
temp = rule.apply(db,p)
|
temp = rule.apply(db,p_id)
|
||||||
test = ((not test) and temp) or (test and (not temp))
|
test = ((not test) and temp) or (test and (not temp))
|
||||||
if self.invert:
|
if self.invert:
|
||||||
return not test
|
return not test
|
||||||
else:
|
else:
|
||||||
return test
|
return test
|
||||||
|
|
||||||
def check_one(self,db,p):
|
def check_one(self,db,p_id):
|
||||||
count = 0
|
count = 0
|
||||||
for rule in self.flist:
|
for rule in self.flist:
|
||||||
if rule.apply(db,p):
|
if rule.apply(db,p_id):
|
||||||
count = count + 1
|
count = count + 1
|
||||||
if count > 1:
|
if count > 1:
|
||||||
break
|
break
|
||||||
@ -1374,10 +1442,10 @@ class GenericFilter:
|
|||||||
else:
|
else:
|
||||||
return count == 1
|
return count == 1
|
||||||
|
|
||||||
def check_and(self,db,p):
|
def check_and(self,db,p_id):
|
||||||
test = 1
|
test = 1
|
||||||
for rule in self.flist:
|
for rule in self.flist:
|
||||||
test = test and rule.apply(db,p)
|
test = test and rule.apply(db,p_id)
|
||||||
if not test:
|
if not test:
|
||||||
break
|
break
|
||||||
if self.invert:
|
if self.invert:
|
||||||
@ -1392,15 +1460,15 @@ class GenericFilter:
|
|||||||
m = self.check_and
|
m = self.check_and
|
||||||
return m
|
return m
|
||||||
|
|
||||||
def check(self,db,p):
|
def check(self,db,p_id):
|
||||||
return self.get_check_func()(db,p)
|
return self.get_check_func()(db,p_id)
|
||||||
|
|
||||||
def apply(self,db,list):
|
def apply(self,db,id_list):
|
||||||
m = self.get_check_func()
|
m = self.get_check_func()
|
||||||
res = []
|
res = []
|
||||||
for p in list:
|
for p_id in id_list:
|
||||||
if m(db,p):
|
if m(db,p_id):
|
||||||
res.append(p)
|
res.append(p_id)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
# Copyright (C) 2000-2003 Donald N. Allingham
|
# Copyright (C) 2000-2004 Donald N. Allingham
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@ -293,8 +293,8 @@ class FilterEditor:
|
|||||||
store,iter = self.clist.get_selected()
|
store,iter = self.clist.get_selected()
|
||||||
if iter:
|
if iter:
|
||||||
filt = self.clist.get_object(iter)
|
filt = self.clist.get_object(iter)
|
||||||
list = filt.apply(self.db,self.db.get_person_id_map().values())
|
id_list = filt.apply(self.db,self.db.get_person_keys())
|
||||||
ShowResults(list)
|
ShowResults(self.db,id_list)
|
||||||
|
|
||||||
def delete_filter(self,obj):
|
def delete_filter(self,obj):
|
||||||
store,iter = self.clist.get_selected()
|
store,iter = self.clist.get_selected()
|
||||||
@ -404,8 +404,9 @@ class FilterEditor:
|
|||||||
self.pmap = {}
|
self.pmap = {}
|
||||||
self.add_places = []
|
self.add_places = []
|
||||||
|
|
||||||
for p in self.db.get_place_ids():
|
for p_id in self.db.get_place_ids():
|
||||||
self.pmap[p.get_title()] = p
|
p = self.db.find_place_from_id(p_id)
|
||||||
|
self.pmap[p.get_title()] = p_id
|
||||||
|
|
||||||
self.active_rule = val
|
self.active_rule = val
|
||||||
self.rule = gtk.glade.XML(const.filterFile,'rule_editor',"gramps")
|
self.rule = gtk.glade.XML(const.filterFile,'rule_editor',"gramps")
|
||||||
@ -588,7 +589,7 @@ class FilterEditor:
|
|||||||
self.rule_top.destroy()
|
self.rule_top.destroy()
|
||||||
|
|
||||||
class ShowResults:
|
class ShowResults:
|
||||||
def __init__(self,plist):
|
def __init__(self,db,id_list):
|
||||||
self.glade = gtk.glade.XML(const.filterFile,'test',"gramps")
|
self.glade = gtk.glade.XML(const.filterFile,'test',"gramps")
|
||||||
self.top = self.glade.get_widget('test')
|
self.top = self.glade.get_widget('test')
|
||||||
text = self.glade.get_widget('text')
|
text = self.glade.get_widget('text')
|
||||||
@ -599,7 +600,8 @@ class ShowResults:
|
|||||||
self.glade.signal_autoconnect({'on_close_clicked' : self.close})
|
self.glade.signal_autoconnect({'on_close_clicked' : self.close})
|
||||||
|
|
||||||
n = []
|
n = []
|
||||||
for p in plist:
|
for p_id in id_list:
|
||||||
|
p = db.find_person_from_id(p_id)
|
||||||
n.append ("%s [%s]\n" % (p.get_primary_name().get_name(),p.get_id()))
|
n.append ("%s [%s]\n" % (p.get_primary_name().get_name(),p.get_id()))
|
||||||
|
|
||||||
n.sort ()
|
n.sort ()
|
||||||
|
@ -314,7 +314,7 @@ class IndividualPage:
|
|||||||
|
|
||||||
if self.photos and len(media_list) > 0:
|
if self.photos and len(media_list) > 0:
|
||||||
object_id = media_list[0].get_reference_id()
|
object_id = media_list[0].get_reference_id()
|
||||||
object = self.database.find_object_from_id(object_id)
|
object = self.db.find_object_from_id(object_id)
|
||||||
if object.get_mime_type()[0:5] == "image":
|
if object.get_mime_type()[0:5] == "image":
|
||||||
src = object.get_path()
|
src = object.get_path()
|
||||||
junk,ext = os.path.splitext(src)
|
junk,ext = os.path.splitext(src)
|
||||||
@ -405,9 +405,9 @@ class IndividualPage:
|
|||||||
|
|
||||||
my_list = []
|
my_list = []
|
||||||
for object_ref in self.person.get_media_list():
|
for object_ref in self.person.get_media_list():
|
||||||
object = self.database.find_object_from_id(object_ref.get_ref())
|
object = self.db.find_object_from_id(object_ref.get_reference_id())
|
||||||
if object.get_mime_type()[0:5] == "image":
|
if object.get_mime_type()[0:5] == "image":
|
||||||
if object.get_privacy() == 0:
|
if object_ref.get_privacy() == 0:
|
||||||
my_list.append(object)
|
my_list.append(object)
|
||||||
|
|
||||||
# if no images were found, return
|
# if no images were found, return
|
||||||
@ -426,10 +426,10 @@ class IndividualPage:
|
|||||||
index = 0
|
index = 0
|
||||||
for obj_id in my_list:
|
for obj_id in my_list:
|
||||||
try:
|
try:
|
||||||
obj = self.database.find_object_from_id(obj_id)
|
obj = self.db.find_object_from_id(obj_id)
|
||||||
src = obj.get_reference().get_path()
|
src = obj.get_path()
|
||||||
junk,ext = os.path.splitext(src)
|
junk,ext = os.path.splitext(src)
|
||||||
base = '%s%s' % (obj.get_reference().get_id(),ext)
|
base = '%s%s' % (obj.get_id(),ext)
|
||||||
|
|
||||||
if self.image_dir:
|
if self.image_dir:
|
||||||
shutil.copyfile(src,"%s/%s/%s" % (self.dir,self.image_dir,base))
|
shutil.copyfile(src,"%s/%s/%s" % (self.dir,self.image_dir,base))
|
||||||
@ -450,7 +450,7 @@ class IndividualPage:
|
|||||||
index = 1
|
index = 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
description = obj.get_reference().get_description()
|
description = obj.get_description()
|
||||||
|
|
||||||
self.doc.start_row()
|
self.doc.start_row()
|
||||||
self.doc.start_cell("ImageCell")
|
self.doc.start_cell("ImageCell")
|
||||||
@ -754,29 +754,34 @@ class WebReport(Report.Report):
|
|||||||
retval = "AFT %s" % retval
|
retval = "AFT %s" % retval
|
||||||
return retval
|
return retval
|
||||||
|
|
||||||
def dump_gendex(self,person_list,html_dir):
|
def dump_gendex(self,person_id_list,html_dir):
|
||||||
fname = "%s/gendex.txt" % html_dir
|
fname = "%s/gendex.txt" % html_dir
|
||||||
try:
|
try:
|
||||||
f = open(fname,"w")
|
f = open(fname,"w")
|
||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
for p in person_list:
|
for p_id in person_id_list:
|
||||||
|
p = self.db.find_person_from_id(p_id)
|
||||||
name = p.get_primary_name()
|
name = p.get_primary_name()
|
||||||
firstName = name.get_first_name()
|
firstName = name.get_first_name()
|
||||||
surName = name.get_surname()
|
surName = name.get_surname()
|
||||||
suffix = name.get_suffix()
|
suffix = name.get_suffix()
|
||||||
|
|
||||||
f.write("%s.%s|" % (p.get_id(),self.ext))
|
f.write("%s.%s|" % (p_id,self.ext))
|
||||||
f.write("%s|" % surName)
|
f.write("%s|" % surName)
|
||||||
if suffix == "":
|
if suffix == "":
|
||||||
f.write("%s /%s/|" % (firstName,surName))
|
f.write("%s /%s/|" % (firstName,surName))
|
||||||
else:
|
else:
|
||||||
f.write("%s /%s/, %s|" % (firstName,surName, suffix))
|
f.write("%s /%s/, %s|" % (firstName,surName, suffix))
|
||||||
for e in [p.get_birth(),p.get_death()]:
|
for e_id in [p.get_birth_id(),p.get_death_id()]:
|
||||||
|
if e_id:
|
||||||
|
e = self.db.find_event_from_id(e_id)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
if e:
|
if e:
|
||||||
f.write("%s|" % self.make_date(e.get_date_object()))
|
f.write("%s|" % self.make_date(e.get_date_object()))
|
||||||
if e.get_place_id():
|
if e.get_place_id():
|
||||||
f.write('%s|' % e.get_place_id().get_title())
|
f.write('%s|' % self.db.find_place_from_id(e.get_place_id()).get_title())
|
||||||
else:
|
else:
|
||||||
f.write('|')
|
f.write('|')
|
||||||
else:
|
else:
|
||||||
@ -784,7 +789,7 @@ class WebReport(Report.Report):
|
|||||||
f.write('\n')
|
f.write('\n')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def dump_index(self,person_list,styles,template,html_dir):
|
def dump_index(self,person_id_list,styles,template,html_dir):
|
||||||
"""Writes an index file, listing all people in the person list."""
|
"""Writes an index file, listing all people in the person list."""
|
||||||
|
|
||||||
doc = HtmlLinkDoc(self.selected_style,None,template,None)
|
doc = HtmlLinkDoc(self.selected_style,None,template,None)
|
||||||
@ -796,10 +801,11 @@ class WebReport(Report.Report):
|
|||||||
doc.write_text(_("Family Tree Index"))
|
doc.write_text(_("Family Tree Index"))
|
||||||
doc.end_paragraph()
|
doc.end_paragraph()
|
||||||
|
|
||||||
person_list.sort(sort.by_last_name)
|
person_id_list.sort(self.db.sort_by_name)
|
||||||
|
|
||||||
a = {}
|
a = {}
|
||||||
for person in person_list:
|
for person_id in person_id_list:
|
||||||
|
person = self.db.find_person_from_id(person_id)
|
||||||
n = person.get_primary_name().get_surname()
|
n = person.get_primary_name().get_surname()
|
||||||
if n:
|
if n:
|
||||||
a[n[0]] = 1
|
a[n[0]] = 1
|
||||||
@ -829,9 +835,9 @@ class WebReport(Report.Report):
|
|||||||
if self.separate_alpha:
|
if self.separate_alpha:
|
||||||
doc.close()
|
doc.close()
|
||||||
for n in link_keys:
|
for n in link_keys:
|
||||||
p_list = [ p for p in person_list if \
|
p_id_list = [ p_id for p_id in person_id_list if \
|
||||||
(p.get_primary_name().get_surname() \
|
(self.db.find_person_from_id(p_id).get_primary_name().get_surname() \
|
||||||
and (p.get_primary_name().get_surname()[0] == n) ) ]
|
and (self.db.find_person_from_id(p_id).get_primary_name().get_surname()[0] == n) ) ]
|
||||||
doc = HtmlLinkDoc(self.selected_style,None,template,None)
|
doc = HtmlLinkDoc(self.selected_style,None,template,None)
|
||||||
doc.set_extension(self.ext)
|
doc.set_extension(self.ext)
|
||||||
doc.set_title(_("Section %s") % n)
|
doc.set_title(_("Section %s") % n)
|
||||||
@ -848,10 +854,10 @@ class WebReport(Report.Report):
|
|||||||
doc.write_raw('<tr><td width="%d%%" valign="top">' % td_width)
|
doc.write_raw('<tr><td width="%d%%" valign="top">' % td_width)
|
||||||
col_len = n_rows
|
col_len = n_rows
|
||||||
|
|
||||||
for person in p_list:
|
for person_id in p_id_list:
|
||||||
name = person.get_primary_name().get_name()
|
name = self.db.find_person_from_if(person_id).get_primary_name().get_name()
|
||||||
|
|
||||||
doc.start_link("%s.%s" % (person.get_id(),self.ext))
|
doc.start_link("%s.%s" % (person_id,self.ext))
|
||||||
doc.write_text(name)
|
doc.write_text(name)
|
||||||
doc.end_link()
|
doc.end_link()
|
||||||
|
|
||||||
@ -864,7 +870,7 @@ class WebReport(Report.Report):
|
|||||||
doc.write_raw('</td></tr></table>')
|
doc.write_raw('</td></tr></table>')
|
||||||
doc.close()
|
doc.close()
|
||||||
else:
|
else:
|
||||||
n_rows = len(person_list) + len(link_keys)
|
n_rows = len(person_id_list) + len(link_keys)
|
||||||
n_rows = n_rows/self.n_cols
|
n_rows = n_rows/self.n_cols
|
||||||
td_width = 100/self.n_cols
|
td_width = 100/self.n_cols
|
||||||
|
|
||||||
@ -872,9 +878,9 @@ class WebReport(Report.Report):
|
|||||||
doc.write_raw('<tr><td width="%d%%" valign="top">' % td_width)
|
doc.write_raw('<tr><td width="%d%%" valign="top">' % td_width)
|
||||||
col_len = n_rows
|
col_len = n_rows
|
||||||
for n in link_keys:
|
for n in link_keys:
|
||||||
p_list = [ p for p in person_list if \
|
p_id_list = [ p_id for p_id in person_id_list if \
|
||||||
(p.get_primary_name().get_surname() \
|
(self.db.find_person_from_id(p_id).get_primary_name().get_surname() \
|
||||||
and (p.get_primary_name().get_surname()[0] == n) ) ]
|
and (self.db.find_person_from_id(p_id).get_primary_name().get_surname()[0] == n) ) ]
|
||||||
doc.start_paragraph('IndexLabel')
|
doc.start_paragraph('IndexLabel')
|
||||||
if self.include_alpha_links:
|
if self.include_alpha_links:
|
||||||
doc.write_linktarget("%03d" % a[n])
|
doc.write_linktarget("%03d" % a[n])
|
||||||
@ -882,10 +888,10 @@ class WebReport(Report.Report):
|
|||||||
doc.end_paragraph()
|
doc.end_paragraph()
|
||||||
col_len = col_len - 1
|
col_len = col_len - 1
|
||||||
|
|
||||||
for person in p_list:
|
for person_id in p_id_list:
|
||||||
name = person.get_primary_name().get_name()
|
name = self.db.find_person_from_id(person_id).get_primary_name().get_name()
|
||||||
|
|
||||||
doc.start_link("%s.%s" % (person.get_id(),self.ext))
|
doc.start_link("%s.%s" % (person_id,self.ext))
|
||||||
doc.write_text(name)
|
doc.write_text(name)
|
||||||
doc.end_link()
|
doc.end_link()
|
||||||
if col_len <= 0:
|
if col_len <= 0:
|
||||||
@ -938,7 +944,7 @@ class WebReport(Report.Report):
|
|||||||
image_dir_name)
|
image_dir_name)
|
||||||
return
|
return
|
||||||
|
|
||||||
ind_list = self.filter.apply(self.db,self.db.get_person_id_map().values())
|
ind_list = self.filter.apply(self.db,self.db.get_person_keys())
|
||||||
self.progress_bar_setup(float(len(ind_list)))
|
self.progress_bar_setup(float(len(ind_list)))
|
||||||
|
|
||||||
doc = HtmlLinkDoc(self.selected_style,None,self.template_name,None)
|
doc = HtmlLinkDoc(self.selected_style,None,self.template_name,None)
|
||||||
@ -950,8 +956,9 @@ class WebReport(Report.Report):
|
|||||||
|
|
||||||
my_map = {}
|
my_map = {}
|
||||||
for l in ind_list:
|
for l in ind_list:
|
||||||
my_map[l.get_id()] = l
|
my_map[l] = l
|
||||||
for person in ind_list:
|
for person_id in ind_list:
|
||||||
|
person = self.db.find_person_from_id(person_id)
|
||||||
tdoc = HtmlLinkDoc(self.selected_style,None,None,None,doc)
|
tdoc = HtmlLinkDoc(self.selected_style,None,None,None,doc)
|
||||||
tdoc.set_extension(self.ext)
|
tdoc.set_extension(self.ext)
|
||||||
tdoc.set_keywords([person.get_primary_name().get_surname(),
|
tdoc.set_keywords([person.get_primary_name().get_surname(),
|
||||||
|
Loading…
Reference in New Issue
Block a user