* src/Filters/_GenericFilter.py (GenericFilterFactory): Add
factory function. * src/Filters/_FilterParser.py (FilterParser.startElement): Use factory function. * src/Filters/Rules/_MatchesFilterBase.py: Add base module. * src/Filters/Rules/Person/_MatchesFilter.py: Derive from base. * src/Filters/Rules/Family/_MatchesFilter.py: Add rule. * src/Filters/Rules/Family/_MotherHasIdOf.py: Add rule. * src/Filters/Rules/Family/_FatherHasIdOf.py: Add rule. * src/Filters/Rules/Family/_MotherHasNameOf.py: Add rule. * src/Filters/Rules/Family/_ChildHasIdOf.py: Add rule. * src/Filters/Rules/Family/_FatherHasNameOf.py: Add rule. * src/Filters/Rules/Family/_ChildHasNameOf.py: Add rule. * src/Filters/Rules/Family/__init__.py: Expose new rules. svn: r7117
This commit is contained in:
		@@ -1,4 +1,19 @@
 | 
			
		||||
2006-08-03  Alex Roitman  <shura@gramps-project.org>
 | 
			
		||||
	* src/Filters/_GenericFilter.py (GenericFilterFactory): Add
 | 
			
		||||
	factory function.
 | 
			
		||||
	* src/Filters/_FilterParser.py (FilterParser.startElement): Use
 | 
			
		||||
	factory function.
 | 
			
		||||
	* src/Filters/Rules/_MatchesFilterBase.py: Add base module.
 | 
			
		||||
	* src/Filters/Rules/Person/_MatchesFilter.py: Derive from base.
 | 
			
		||||
	* src/Filters/Rules/Family/_MatchesFilter.py: Add rule.
 | 
			
		||||
	* src/Filters/Rules/Family/_MotherHasIdOf.py: Add rule.
 | 
			
		||||
	* src/Filters/Rules/Family/_FatherHasIdOf.py: Add rule.
 | 
			
		||||
	* src/Filters/Rules/Family/_MotherHasNameOf.py: Add rule.
 | 
			
		||||
	* src/Filters/Rules/Family/_ChildHasIdOf.py: Add rule.
 | 
			
		||||
	* src/Filters/Rules/Family/_FatherHasNameOf.py: Add rule.
 | 
			
		||||
	* src/Filters/Rules/Family/_ChildHasNameOf.py: Add rule.
 | 
			
		||||
	* src/Filters/Rules/Family/__init__.py: Expose new rules.
 | 
			
		||||
	
 | 
			
		||||
	* src/GrampsLogger/_ErrorReportAssistant.py (build_page5): Typo.
 | 
			
		||||
	* src/Filters/Rules/Person/_HasIdOf.py: Cleanup.
 | 
			
		||||
	* src/Filters/Rules/Person/__init__.py (editor_rule_list): Add
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										56
									
								
								gramps2/src/Filters/Rules/Family/_ChildHasIdOf.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								gramps2/src/Filters/Rules/Family/_ChildHasIdOf.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,56 @@
 | 
			
		||||
#
 | 
			
		||||
# 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: _HasNameOf.py 6529 2006-05-03 06:29:07Z rshura $
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# Standard Python modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from gettext import gettext as _
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# GRAMPS modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from Filters.Rules import HasGrampsId
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# HasNameOf
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
class ChildHasIdOf(HasGrampsId):
 | 
			
		||||
    """Rule that checks for a person with a specific GRAMPS ID"""
 | 
			
		||||
 | 
			
		||||
    labels      = [ _('Person ID:') ]
 | 
			
		||||
    name        = _('Families with child with the <Id>')
 | 
			
		||||
    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
 | 
			
		||||
							
								
								
									
										55
									
								
								gramps2/src/Filters/Rules/Family/_ChildHasNameOf.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										55
									
								
								gramps2/src/Filters/Rules/Family/_ChildHasNameOf.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,55 @@
 | 
			
		||||
#
 | 
			
		||||
# 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: _HasNameOf.py 6529 2006-05-03 06:29:07Z rshura $
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# Standard Python modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from gettext import gettext as _
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# GRAMPS modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from Filters.Rules.Person import HasNameOf
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# HasNameOf
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
class ChildHasNameOf(HasNameOf):
 | 
			
		||||
    """Rule that checks for full or partial name matches"""
 | 
			
		||||
 | 
			
		||||
    name        = _('Families with child with the <name>')
 | 
			
		||||
    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
 | 
			
		||||
							
								
								
									
										54
									
								
								gramps2/src/Filters/Rules/Family/_FatherHasIdOf.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								gramps2/src/Filters/Rules/Family/_FatherHasIdOf.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
#
 | 
			
		||||
# 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: _HasNameOf.py 6529 2006-05-03 06:29:07Z rshura $
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# Standard Python modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from gettext import gettext as _
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# GRAMPS modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from Filters.Rules import HasGrampsId
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# HasNameOf
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
class FatherHasIdOf(HasGrampsId):
 | 
			
		||||
    """Rule that checks for a person with a specific GRAMPS ID"""
 | 
			
		||||
 | 
			
		||||
    labels      = [ _('Person ID:') ]
 | 
			
		||||
    name        = _('Families with father with the <Id>')
 | 
			
		||||
    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)
 | 
			
		||||
        return HasGrampsId.apply(self,db,father)
 | 
			
		||||
							
								
								
									
										53
									
								
								gramps2/src/Filters/Rules/Family/_FatherHasNameOf.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								gramps2/src/Filters/Rules/Family/_FatherHasNameOf.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
#
 | 
			
		||||
# 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: _HasNameOf.py 6529 2006-05-03 06:29:07Z rshura $
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# Standard Python modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from gettext import gettext as _
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# GRAMPS modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from Filters.Rules.Person import HasNameOf
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# HasNameOf
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
class FatherHasNameOf(HasNameOf):
 | 
			
		||||
    """Rule that checks for full or partial name matches"""
 | 
			
		||||
 | 
			
		||||
    name        = _('Families with father with the <name>')
 | 
			
		||||
    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)
 | 
			
		||||
        return HasNameOf.apply(self,db,father)
 | 
			
		||||
							
								
								
									
										47
									
								
								gramps2/src/Filters/Rules/Family/_MatchesFilter.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								gramps2/src/Filters/Rules/Family/_MatchesFilter.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,47 @@
 | 
			
		||||
#
 | 
			
		||||
# 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: _MatchesFilter.py 6932 2006-06-21 16:30:35Z dallingham $
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# Standard Python modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from gettext import gettext as _
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# GRAMPS modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# MatchesFilter
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
class MatchesFilter(MatchesFilterBase):
 | 
			
		||||
    """Rule that checks against another filter"""
 | 
			
		||||
 | 
			
		||||
    name        = _('Families matching the <filter>')
 | 
			
		||||
    description = _("Matches families macthed by the specified filter name")
 | 
			
		||||
    namespace   = 'Family'
 | 
			
		||||
							
								
								
									
										54
									
								
								gramps2/src/Filters/Rules/Family/_MotherHasIdOf.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								gramps2/src/Filters/Rules/Family/_MotherHasIdOf.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
			
		||||
#
 | 
			
		||||
# 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: _HasNameOf.py 6529 2006-05-03 06:29:07Z rshura $
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# Standard Python modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from gettext import gettext as _
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# GRAMPS modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from Filters.Rules import HasGrampsId
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# HasNameOf
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
class MotherHasIdOf(HasGrampsId):
 | 
			
		||||
    """Rule that checks for a person with a specific GRAMPS ID"""
 | 
			
		||||
 | 
			
		||||
    labels      = [ _('Person ID:') ]
 | 
			
		||||
    name        = _('Families with mother with the <Id>')
 | 
			
		||||
    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)
 | 
			
		||||
        return HasGrampsId.apply(self,db,mother)
 | 
			
		||||
							
								
								
									
										53
									
								
								gramps2/src/Filters/Rules/Family/_MotherHasNameOf.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										53
									
								
								gramps2/src/Filters/Rules/Family/_MotherHasNameOf.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,53 @@
 | 
			
		||||
#
 | 
			
		||||
# 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: _HasNameOf.py 6529 2006-05-03 06:29:07Z rshura $
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# Standard Python modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from gettext import gettext as _
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# GRAMPS modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from Filters.Rules.Person import HasNameOf
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# HasNameOf
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
class MotherHasNameOf(HasNameOf):
 | 
			
		||||
    """Rule that checks for full or partial name matches"""
 | 
			
		||||
 | 
			
		||||
    name        = _('Families with mother with the <name>')
 | 
			
		||||
    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)
 | 
			
		||||
        return HasNameOf.apply(self,db,mother)
 | 
			
		||||
@@ -34,6 +34,13 @@ from _HasNoteRegexp import HasNoteRegexp
 | 
			
		||||
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
 | 
			
		||||
from _FamilyPrivate import FamilyPrivate
 | 
			
		||||
from _HasEvent import HasEvent
 | 
			
		||||
from _MatchesFilter import MatchesFilter
 | 
			
		||||
from _FatherHasNameOf import FatherHasNameOf
 | 
			
		||||
from _FatherHasIdOf import FatherHasIdOf
 | 
			
		||||
from _MotherHasNameOf import MotherHasNameOf
 | 
			
		||||
from _MotherHasIdOf import MotherHasIdOf
 | 
			
		||||
from _ChildHasNameOf import ChildHasNameOf
 | 
			
		||||
from _ChildHasIdOf import ChildHasIdOf
 | 
			
		||||
 | 
			
		||||
editor_rule_list = [
 | 
			
		||||
    AllFamilies,
 | 
			
		||||
@@ -44,4 +51,11 @@ editor_rule_list = [
 | 
			
		||||
    HasNoteMatchingSubstringOf,
 | 
			
		||||
    FamilyPrivate,
 | 
			
		||||
    HasEvent,
 | 
			
		||||
    MatchesFilter,
 | 
			
		||||
    FatherHasNameOf,
 | 
			
		||||
    FatherHasIdOf,
 | 
			
		||||
    MotherHasNameOf,
 | 
			
		||||
    MotherHasIdOf,
 | 
			
		||||
    ChildHasNameOf,
 | 
			
		||||
    ChildHasIdOf,
 | 
			
		||||
]
 | 
			
		||||
 
 | 
			
		||||
@@ -32,54 +32,16 @@ from gettext import gettext as _
 | 
			
		||||
# GRAMPS modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
import Filters
 | 
			
		||||
#from Filters import SystemFilters, CustomFilters
 | 
			
		||||
from Filters.Rules._Rule import Rule
 | 
			
		||||
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# MatchesFilter
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
class MatchesFilter(Rule):
 | 
			
		||||
class MatchesFilter(MatchesFilterBase):
 | 
			
		||||
    """Rule that checks against another filter"""
 | 
			
		||||
 | 
			
		||||
    labels      = [_('Filter name:')]
 | 
			
		||||
    name        = _('People matching the <filter>')
 | 
			
		||||
    description = _("Matches people macthed by the specified filter name")
 | 
			
		||||
    category    = _('General filters')
 | 
			
		||||
 | 
			
		||||
    def prepare(self,db):
 | 
			
		||||
	if Filters.SystemFilters:
 | 
			
		||||
	    for filt in Filters.SystemFilters.get_filters('Person'):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    for rule in filt.flist:
 | 
			
		||||
			rule.prepare(db)
 | 
			
		||||
	if Filters.CustomFilters:
 | 
			
		||||
	    for filt in Filters.CustomFilters.get_filters('Person'):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    for rule in filt.flist:
 | 
			
		||||
			rule.prepare(db)
 | 
			
		||||
 | 
			
		||||
    def reset(self):
 | 
			
		||||
	if Filters.SystemFilters:
 | 
			
		||||
	    for filt in Filters.SystemFilters.get_filters('Person'):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    for rule in filt.flist:
 | 
			
		||||
			rule.reset()
 | 
			
		||||
	if Filters.CustomFilters:
 | 
			
		||||
	    for filt in Filters.CustomFilters.get_filters('Person'):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    for rule in filt.flist:
 | 
			
		||||
			rule.reset()
 | 
			
		||||
 | 
			
		||||
    def apply(self,db,person):
 | 
			
		||||
	if Filters.SystemFilters:
 | 
			
		||||
	    for filt in Filters.SystemFilters.get_filters('Person'):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    return filt.check(db,person.handle)
 | 
			
		||||
	if Filters.CustomFilters:
 | 
			
		||||
	    for filt in Filters.CustomFilters.get_filters('Person'):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    return filt.check(db,person.handle)
 | 
			
		||||
        return False
 | 
			
		||||
    namespace   = 'Person'
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										89
									
								
								gramps2/src/Filters/Rules/_MatchesFilterBase.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								gramps2/src/Filters/Rules/_MatchesFilterBase.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,89 @@
 | 
			
		||||
#
 | 
			
		||||
# 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: _MatchesFilter.py 6932 2006-06-21 16:30:35Z dallingham $
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# Standard Python modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from gettext import gettext as _
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# GRAMPS modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
import Filters
 | 
			
		||||
from _Rule import Rule
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# MatchesFilter
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
class MatchesFilterBase(Rule):
 | 
			
		||||
    """
 | 
			
		||||
    Rule that checks against another filter.
 | 
			
		||||
 | 
			
		||||
    This is a base rule for subclassing by specific objects.
 | 
			
		||||
    Subclasses need to define the namespace class attribute.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    labels      = [_('Filter name:')]
 | 
			
		||||
    name        = _('Objects matching the <filter>')
 | 
			
		||||
    description = _("Matches objects macthed by the specified filter name")
 | 
			
		||||
    category    = _('General filters')
 | 
			
		||||
 | 
			
		||||
    def prepare(self,db):
 | 
			
		||||
	if Filters.SystemFilters:
 | 
			
		||||
	    for filt in Filters.SystemFilters.get_filters(self.namespace):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    for rule in filt.flist:
 | 
			
		||||
			rule.prepare(db)
 | 
			
		||||
	if Filters.CustomFilters:
 | 
			
		||||
	    for filt in Filters.CustomFilters.get_filters(self.namespace):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    for rule in filt.flist:
 | 
			
		||||
			rule.prepare(db)
 | 
			
		||||
 | 
			
		||||
    def reset(self):
 | 
			
		||||
	if Filters.SystemFilters:
 | 
			
		||||
	    for filt in Filters.SystemFilters.get_filters(self.namespace):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    for rule in filt.flist:
 | 
			
		||||
			rule.reset()
 | 
			
		||||
	if Filters.CustomFilters:
 | 
			
		||||
	    for filt in Filters.CustomFilters.get_filters(self.namespace):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    for rule in filt.flist:
 | 
			
		||||
			rule.reset()
 | 
			
		||||
 | 
			
		||||
    def apply(self,db,obj):
 | 
			
		||||
	if Filters.SystemFilters:
 | 
			
		||||
	    for filt in Filters.SystemFilters.get_filters(self.namespace):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    return filt.check(db,obj.handle)
 | 
			
		||||
	if Filters.CustomFilters:
 | 
			
		||||
	    for filt in Filters.CustomFilters.get_filters(self.namespace):
 | 
			
		||||
		if filt.get_name() == self.list[0]:
 | 
			
		||||
		    return filt.check(db,obj.handle)
 | 
			
		||||
        return False
 | 
			
		||||
@@ -32,7 +32,7 @@ from xml.sax import handler
 | 
			
		||||
# Gramps modules
 | 
			
		||||
#
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
from _GenericFilter import GenericFilter
 | 
			
		||||
from _GenericFilter import GenericFilterFactory
 | 
			
		||||
import Rules
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
@@ -62,7 +62,7 @@ class FilterParser(handler.ContentHandler):
 | 
			
		||||
            else:
 | 
			
		||||
                self.namespace = "generic"
 | 
			
		||||
        elif tag == "filter":
 | 
			
		||||
            self.f = GenericFilter()
 | 
			
		||||
            self.f = GenericFilterFactory(self.namespace)()
 | 
			
		||||
            self.f.set_name(attrs['name'])
 | 
			
		||||
            if attrs.has_key('function'):
 | 
			
		||||
                try:
 | 
			
		||||
 
 | 
			
		||||
@@ -25,7 +25,6 @@ Package providing filtering framework for GRAMPS.
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
import RelLib
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------
 | 
			
		||||
#
 | 
			
		||||
# GenericFilter
 | 
			
		||||
@@ -210,3 +209,8 @@ class GenericFamilyFilter(GenericFilter):
 | 
			
		||||
        return db.get_family_from_handle(handle)
 | 
			
		||||
 | 
			
		||||
    
 | 
			
		||||
def GenericFilterFactory(namespace):
 | 
			
		||||
    if namespace == 'Person':
 | 
			
		||||
        return GenericFilter
 | 
			
		||||
    elif namespace == 'Family':
 | 
			
		||||
        return GenericFamilyFilter
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user