diff --git a/ChangeLog b/ChangeLog index 5b96fa9f4..46d1ef8ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,6 @@ 2006-08-05 Alex Roitman + * src/Filters/Rules/Family/Makefile.am (pkgdata_PYTHON): Ship new file. + * src/Filters/Rules/Family/_MemberBase.py: Add new module. * src/Filters/SideBar/_PersonSidebarFilter.py: Minor changes. * src/Filters/SideBar/_FamilySidebarFilter.py: Add father, mother, and child search options. diff --git a/po/ChangeLog b/po/ChangeLog index 045c09aed..9c76269b2 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,6 +1,6 @@ 2006-08-05 Alex Roitman * POTFILES.in: Add new files. - + 2006-08-04 Alex Roitman * POTFILES.in: Unlist plugins that are not shipped. Add new files. diff --git a/po/POTFILES.in b/po/POTFILES.in index 87c04e62c..e39b73ed0 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -506,6 +506,7 @@ src/Filters/Rules/Family/_ChildHasNameOf.py src/Filters/Rules/Family/_SearchFatherName.py src/Filters/Rules/Family/_SearchChildName.py src/Filters/Rules/Family/_SearchMotherName.py +src/Filters/Rules/Family/_MemberBase.py # Filters.Rules.Event package src/Filters/Rules/Event/_MatchesFilter.py diff --git a/src/Filters/Rules/Family/Makefile.am b/src/Filters/Rules/Family/Makefile.am index 244a90a02..7f4103e0a 100644 --- a/src/Filters/Rules/Family/Makefile.am +++ b/src/Filters/Rules/Family/Makefile.am @@ -20,9 +20,10 @@ pkgdata_PYTHON = \ _MotherHasIdOf.py\ _ChildHasNameOf.py\ _ChildHasIdOf.py\ - _SearchFatherName\ - _SearchMotherName\ - _SearchChildName + _SearchFatherName.py\ + _SearchMotherName.py\ + _SearchChildName.py\ + _MemberBase.py pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Family diff --git a/src/Filters/Rules/Family/_ChildHasIdOf.py b/src/Filters/Rules/Family/_ChildHasIdOf.py index 5e9c16df0..f67f275ad 100644 --- a/src/Filters/Rules/Family/_ChildHasIdOf.py +++ b/src/Filters/Rules/Family/_ChildHasIdOf.py @@ -33,6 +33,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- from Filters.Rules import HasGrampsId +from _MemberBase import child_base #------------------------------------------------------------------------- # @@ -47,10 +48,5 @@ class ChildHasIdOf(HasGrampsId): description = _("Matches familis where child has a specified " "GRAMPS ID") category = _('Child filters') - - def apply(self,db,family): - for child_ref in family.get_child_ref_list(): - child = db.get_person_from_handle(child_ref.ref) - if HasGrampsId.apply(self,db,child): - return True - return False + base_class = HasGrampsId + apply = child_base diff --git a/src/Filters/Rules/Family/_ChildHasNameOf.py b/src/Filters/Rules/Family/_ChildHasNameOf.py index 854a185cd..df2385375 100644 --- a/src/Filters/Rules/Family/_ChildHasNameOf.py +++ b/src/Filters/Rules/Family/_ChildHasNameOf.py @@ -33,6 +33,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- from Filters.Rules.Person import HasNameOf +from _MemberBase import child_base #------------------------------------------------------------------------- # @@ -46,10 +47,5 @@ class ChildHasNameOf(HasNameOf): description = _("Matches familis where child has a specified " "(partial) name") category = _('Child filters') - - def apply(self,db,family): - for child_ref in family.get_child_ref_list(): - child = db.get_person_from_handle(child_ref.ref) - if HasNameOf.apply(self,db,child): - return True - return False + base_class = HasNameOf + apply = child_base diff --git a/src/Filters/Rules/Family/_FatherHasIdOf.py b/src/Filters/Rules/Family/_FatherHasIdOf.py index d159c3297..f46f3ab0d 100644 --- a/src/Filters/Rules/Family/_FatherHasIdOf.py +++ b/src/Filters/Rules/Family/_FatherHasIdOf.py @@ -33,6 +33,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- from Filters.Rules import HasGrampsId +from _MemberBase import father_base #------------------------------------------------------------------------- # @@ -47,11 +48,5 @@ class FatherHasIdOf(HasGrampsId): description = _("Matches familis whose father has a specified " "GRAMPS ID") category = _('Father filters') - - def apply(self,db,family): - father_handle = family.get_father_handle() - father = db.get_person_from_handle(father_handle) - if father: - return HasGrampsId.apply(self,db,father) - else: - return False + base_class = HasGrampsId + apply = father_base diff --git a/src/Filters/Rules/Family/_FatherHasNameOf.py b/src/Filters/Rules/Family/_FatherHasNameOf.py index 95fd1a7d3..33e1bd514 100644 --- a/src/Filters/Rules/Family/_FatherHasNameOf.py +++ b/src/Filters/Rules/Family/_FatherHasNameOf.py @@ -33,6 +33,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- from Filters.Rules.Person import HasNameOf +from _MemberBase import father_base #------------------------------------------------------------------------- # @@ -46,11 +47,5 @@ class FatherHasNameOf(HasNameOf): description = _("Matches familis whose father has a specified " "(partial) name") category = _('Father filters') - - def apply(self,db,family): - father_handle = family.get_father_handle() - father = db.get_person_from_handle(father_handle) - if father: - return HasNameOf.apply(self,db,father) - else: - return False + base_class = HasNameOf + apply = father_base diff --git a/src/Filters/Rules/Family/_MemberBase.py b/src/Filters/Rules/Family/_MemberBase.py new file mode 100644 index 000000000..9fdab2282 --- /dev/null +++ b/src/Filters/Rules/Family/_MemberBase.py @@ -0,0 +1,57 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2002-2006 Donald N. Allingham +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +# $Id$ + +""" +Set of wrappers for family filter rules based on personal rules. + +Any rule that matches family based on personal rule applied +to father, mather, or any child, just needs to do two things: +1. Set the class attribute 'base_class' to the personal rule +2. Set apply method to be an appropriate wrapper below +Example: +in the class body, outside any method: + base_class = SearchName + apply = child_base +""" + +def father_base(self,db,family): + father_handle = family.get_father_handle() + father = db.get_person_from_handle(father_handle) + if father: + return self.base_class.apply(self,db,father) + else: + return False + +def mother_base(self,db,family): + mother_handle = family.get_mother_handle() + mother = db.get_person_from_handle(mother_handle) + if mother: + return self.base_class.apply(self,db,mother) + else: + return False + +def child_base(self,db,family): + for child_ref in family.get_child_ref_list(): + child = db.get_person_from_handle(child_ref.ref) + if self.base_class.apply(self,db,child): + return True + return False diff --git a/src/Filters/Rules/Family/_MotherHasIdOf.py b/src/Filters/Rules/Family/_MotherHasIdOf.py index 747137755..6e88a2388 100644 --- a/src/Filters/Rules/Family/_MotherHasIdOf.py +++ b/src/Filters/Rules/Family/_MotherHasIdOf.py @@ -33,6 +33,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- from Filters.Rules import HasGrampsId +from _MemberBase import mother_base #------------------------------------------------------------------------- # @@ -47,11 +48,5 @@ class MotherHasIdOf(HasGrampsId): description = _("Matches familis whose mother has a specified " "GRAMPS ID") category = _('Mother filters') - - def apply(self,db,family): - mother_handle = family.get_mother_handle() - mother = db.get_person_from_handle(mother_handle) - if mother: - return HasGrampsId.apply(self,db,mother) - else: - return False + base_class = HasGrampsId + apply = mother_base diff --git a/src/Filters/Rules/Family/_MotherHasNameOf.py b/src/Filters/Rules/Family/_MotherHasNameOf.py index 0cceebe0e..d0011fa5f 100644 --- a/src/Filters/Rules/Family/_MotherHasNameOf.py +++ b/src/Filters/Rules/Family/_MotherHasNameOf.py @@ -33,6 +33,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- from Filters.Rules.Person import HasNameOf +from _MemberBase import mother_base #------------------------------------------------------------------------- # @@ -46,11 +47,5 @@ class MotherHasNameOf(HasNameOf): description = _("Matches familis whose mother has a specified " "(partial) name") category = _('Mother filters') - - def apply(self,db,family): - mother_handle = family.get_mother_handle() - mother = db.get_person_from_handle(mother_handle) - if mother: - return HasNameOf.apply(self,db,mother) - else: - return False + base_class = HasNameOf + apply = mother_base diff --git a/src/Filters/Rules/Family/_SearchChildName.py b/src/Filters/Rules/Family/_SearchChildName.py index 81e6dc5f6..62c109636 100644 --- a/src/Filters/Rules/Family/_SearchChildName.py +++ b/src/Filters/Rules/Family/_SearchChildName.py @@ -33,6 +33,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- from Filters.Rules.Person import SearchName +from _MemberBase import child_base #------------------------------------------------------------------------- # @@ -46,10 +47,5 @@ class SearchChildName(SearchName): description = _("Matches families where any child has a specified " "(partial) name") category = _('Child filters') - - def apply(self,db,family): - for child_ref in family.get_child_ref_list(): - child = db.get_person_from_handle(child_ref.ref) - if SearchName.apply(self,db,child): - return True - return False + base_class = SearchName + apply = child_base diff --git a/src/Filters/Rules/Family/_SearchFatherName.py b/src/Filters/Rules/Family/_SearchFatherName.py index 1875fa196..a37f446f8 100644 --- a/src/Filters/Rules/Family/_SearchFatherName.py +++ b/src/Filters/Rules/Family/_SearchFatherName.py @@ -33,6 +33,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- from Filters.Rules.Person import SearchName +from _MemberBase import father_base #------------------------------------------------------------------------- # @@ -46,11 +47,5 @@ class SearchFatherName(SearchName): description = _("Matches families whose father has a specified " "(partial) name") category = _('Father filters') - - def apply(self,db,family): - father_handle = family.get_father_handle() - father = db.get_person_from_handle(father_handle) - if father: - return SearchName.apply(self,db,father) - else: - return False + base_class = SearchName + apply = father_base diff --git a/src/Filters/Rules/Family/_SearchMotherName.py b/src/Filters/Rules/Family/_SearchMotherName.py index 7e7cd0b75..899f0238b 100644 --- a/src/Filters/Rules/Family/_SearchMotherName.py +++ b/src/Filters/Rules/Family/_SearchMotherName.py @@ -33,6 +33,7 @@ from gettext import gettext as _ # #------------------------------------------------------------------------- from Filters.Rules.Person import SearchName +from _MemberBase import mother_base #------------------------------------------------------------------------- # @@ -46,11 +47,5 @@ class SearchMotherName(SearchName): description = _("Matches families whose mother has a specified " "(partial) name") category = _('Mother filters') - - def apply(self,db,family): - mother_handle = family.get_mother_handle() - mother = db.get_person_from_handle(mother_handle) - if mother: - return SearchName.apply(self,db,mother) - else: - return False + base_class = SearchName + apply = mother_base