2006-07-12 Don Allingham <don@gramps-project.org>

* src/Filters/Rules/Family/_RegExpIdOf.py: new family filter
	* src/Filters/Rules/Family/_HasNoteRegexp.py: new family filter
	* src/Filters/Rules/Family/_HasIdOf.py: new family filter
	* src/Filters/Rules/Family/__init__.py: add new filters
	* src/Filters/Rules/Family/_HasNoteMatchingSubstringOf.py: new family filter
	* src/Filters/Rules/Family/_AllFamilies.py: new family filter
	* src/Filters/Rules/_HasNoteSubstrBase.py: new common bases
	* src/Filters/Rules/_RegExpIdBase.py: new common bases
	* src/Filters/Rules/_HasGrampsId.py: new common bases
	* src/Filters/Rules/Person/__init__.py: update
	* src/Filters/Rules/Person/_HasIdOf.py: use new common base
	* src/Filters/Rules/Person/_HasNoteRegexp.py: use new common base
	* src/Filters/Rules/_HasNoteRegexBase.py: new common base
	* src/Filters/_FamilySidebarFilter.py: use family filters instead of
	person filters



svn: r7020
This commit is contained in:
Don Allingham 2006-07-12 19:20:54 +00:00
parent 88f90e3ecd
commit ad5130dbf6
16 changed files with 489 additions and 24 deletions

View File

@ -1,3 +1,20 @@
2006-07-12 Don Allingham <don@gramps-project.org>
* src/Filters/Rules/Family/_RegExpIdOf.py: new family filter
* src/Filters/Rules/Family/_HasNoteRegexp.py: new family filter
* src/Filters/Rules/Family/_HasIdOf.py: new family filter
* src/Filters/Rules/Family/__init__.py: add new filters
* src/Filters/Rules/Family/_HasNoteMatchingSubstringOf.py: new family filter
* src/Filters/Rules/Family/_AllFamilies.py: new family filter
* src/Filters/Rules/_HasNoteSubstrBase.py: new common bases
* src/Filters/Rules/_RegExpIdBase.py: new common bases
* src/Filters/Rules/_HasGrampsId.py: new common bases
* src/Filters/Rules/Person/__init__.py: update
* src/Filters/Rules/Person/_HasIdOf.py: use new common base
* src/Filters/Rules/Person/_HasNoteRegexp.py: use new common base
* src/Filters/Rules/_HasNoteRegexBase.py: new common base
* src/Filters/_FamilySidebarFilter.py: use family filters instead of
person filters
2006-07-11 Don Allingham <don@gramps-project.org> 2006-07-11 Don Allingham <don@gramps-project.org>
* po/gramps.pot: remove autogenerated file * po/gramps.pot: remove autogenerated file
* src/ViewManager.py: fix default state of filter menu item * src/ViewManager.py: fix default state of filter menu item

View 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: _Everything.py 6529 2006-05-03 06:29:07Z rshura $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._Everything import Everything
#-------------------------------------------------------------------------
#
# Everyone
#
#-------------------------------------------------------------------------
class AllFamilies(Everything):
"""Matches Everyone"""
name = _('Every family')
description = _('Matches every family in the database')

View File

@ -0,0 +1,49 @@
#
# 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: _HasIdOf.py 6529 2006-05-03 06:29:07Z rshura $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import HasGrampsId
#-------------------------------------------------------------------------
#
# HasIdOf
#
#-------------------------------------------------------------------------
class HasIdOf(HasGrampsId):
"""Rule that checks for a person with a specific GRAMPS ID"""
labels = [ _('ID:') ]
name = _('Family with <Id>')
description = _("Matches a family with a specified GRAMPS ID")
category = _('General filters')

View File

@ -0,0 +1,45 @@
#
# 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: _HasNoteMatchingSubstringOf.py 6634 2006-05-12 22:38:48Z dallingham $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasNoteSubstrBase import HasNoteSubstrBase
#-------------------------------------------------------------------------
# "People having notes that contain a substring"
#-------------------------------------------------------------------------
class HasNoteMatchingSubstringOf(HasNoteSubstrBase):
"""People having notes containing <subtring>"""
name = _('Families having notes containing <substring>')
description = _("Matches families whose notes contain text matching a substring")

View File

@ -0,0 +1,46 @@
#
# 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: _HasNoteMatchingSubstringOf.py 6529 2006-05-03 06:29:07Z rshura $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
import re
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasNoteRegexBase import HasNoteRegexBase
#-------------------------------------------------------------------------
# "People having notes that contain a substring"
#-------------------------------------------------------------------------
class HasNoteRegexp(HasNoteRegexBase):
name = _('Families having notes containing <regular expression>')
description = _("Matches families whose notes contain text "
"matching a regular expression")

View File

@ -0,0 +1,48 @@
#
# 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: _HasIdOf.py 6529 2006-05-03 06:29:07Z rshura $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
import re
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._RegExpIdBase import RegExpIdBase
#-------------------------------------------------------------------------
#
# HasIdOf
#
#-------------------------------------------------------------------------
class RegExpIdOf(RegExpIdBase):
"""Rule that checks for a person with a specific GRAMPS ID"""
name = _('Families with <Id>')
description = _("Matches families with a GRAMPS ID that contains the regular expression")

View File

@ -27,7 +27,17 @@ Package providing filter rules for GRAMPS.
__author__ = "Don Allingham" __author__ = "Don Allingham"
from _HasRelType import HasRelType from _HasRelType import HasRelType
from _AllFamilies import AllFamilies
from _HasIdOf import HasIdOf
from _RegExpIdOf import RegExpIdOf
from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
editor_rule_list = [ editor_rule_list = [
AllFamilies,
HasRelType, HasRelType,
HasIdOf,
RegExpIdOf,
HasNoteRegexp,
HasNoteMatchingSubstringOf,
] ]

View File

@ -32,14 +32,14 @@ from gettext import gettext as _
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from Filters.Rules._Rule import Rule from Filters.Rules import HasGrampsId
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# HasIdOf # HasIdOf
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class HasIdOf(Rule): class HasIdOf(HasGrampsId):
"""Rule that checks for a person with a specific GRAMPS ID""" """Rule that checks for a person with a specific GRAMPS ID"""
labels = [ _('ID:') ] labels = [ _('ID:') ]
@ -47,5 +47,3 @@ class HasIdOf(Rule):
description = _("Matches people with a specified GRAMPS ID") description = _("Matches people with a specified GRAMPS ID")
category = _('General filters') category = _('General filters')
def apply(self,db,person):
return person.gramps_id == self.list[0]

View File

@ -25,7 +25,6 @@
# Standard Python modules # Standard Python modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import re
from gettext import gettext as _ from gettext import gettext as _
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -33,28 +32,14 @@ from gettext import gettext as _
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from Filters.Rules._Rule import Rule from Filters.Rules._HasNoteRegexBase import HasNoteRegexBase
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# "People having notes that contain a substring" # "People having notes that contain a substring"
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class HasNoteRegexp(Rule): class HasNoteRegexp(HasNoteRegexBase):
"""People having notes containing <subtring>"""
labels = [ _('Regular expression:')]
name = _('People having notes containing <regular expression>') name = _('People having notes containing <regular expression>')
description = _("Matches people whose notes contain text " description = _("Matches people whose notes contain text "
"matching a regular expression") "matching a regular expression")
category = _('General filters')
def __init__(self, list):
Rule.__init__(self, list)
try:
self.match = re.compile(list[0],re.I|re.U|re.L)
except:
self.match = re.compile('')
def apply(self,db,person):
n = person.get_note()
return self.match.match(n) != None

View File

@ -150,5 +150,5 @@ editor_rule_list = [
RelationshipPathBetweenBookmarks, RelationshipPathBetweenBookmarks,
HasTextMatchingSubstringOf, HasTextMatchingSubstringOf,
HasNote, HasNote,
HasNoteMatchingSubstringOf HasNoteRegexp,
] ]

View File

@ -0,0 +1,48 @@
#
# 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: _HasIdOf.py 6529 2006-05-03 06:29:07Z rshura $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#
# HasIdOf
#
#-------------------------------------------------------------------------
class HasGrampsId(Rule):
"""Rule that checks for a person with a specific GRAMPS ID"""
labels = [ _('ID:') ]
name = _('Object with <Id>')
description = _("Matches objects with a specified GRAMPS ID")
category = _('General filters')

View File

@ -0,0 +1,60 @@
#
# 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: _HasNoteMatchingSubstringOf.py 6529 2006-05-03 06:29:07Z rshura $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
import re
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
#-------------------------------------------------------------------------
# "People having notes that contain a substring"
#-------------------------------------------------------------------------
class HasNoteRegexBase(Rule):
"""People having notes containing <subtring>"""
labels = [ _('Regular expression:')]
name = _('Objects having notes containing <regular expression>')
description = _("Matches objects whose notes contain text "
"matching a regular expression")
category = _('General filters')
def __init__(self, list):
Rule.__init__(self, list)
try:
self.match = re.compile(list[0],re.I|re.U|re.L)
except:
self.match = re.compile('')
def apply(self,db,person):
n = person.get_note()
return self.match.match(n) != None

View File

@ -0,0 +1,52 @@
#
# 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: _HasNoteMatchingSubstringOf.py 6634 2006-05-12 22:38:48Z dallingham $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "People having notes that contain a substring"
#-------------------------------------------------------------------------
class HasNoteSubstrBase(Rule):
"""People having notes containing <subtring>"""
labels = [ _('Substring:')]
name = _('Objects having notes containing <substring>')
description = _("Matches objects whose notes contain text matching a substring")
category = _('General filters')
def apply(self,db,person):
n = person.get_note()
if n:
return n.upper().find(self.list[0].upper()) != -1
return False

View File

@ -0,0 +1,60 @@
#
# 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: _HasIdOf.py 6529 2006-05-03 06:29:07Z rshura $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
import re
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
#-------------------------------------------------------------------------
#
# HasIdOf
#
#-------------------------------------------------------------------------
class RegExpIdBase(Rule):
"""Rule that checks for a person with a specific GRAMPS ID"""
labels = [ _('ID:') ]
name = _('Families with <Id>')
description = _("Matches families with a GRAMPS ID that contains the regular expression")
category = _('General filters')
def __init__(self, list):
Rule.__init__(self, list)
try:
self.match = re.compile(list[0],re.I|re.U|re.L)
except:
self.match = re.compile('')
def apply(self,db,person):
return self.match.match(person.gramps_id) != None

View File

@ -27,6 +27,7 @@ Package providing filter rules for GRAMPS.
__author__ = "Don Allingham" __author__ = "Don Allingham"
from _Everything import Everything from _Everything import Everything
from _HasGrampsId import HasGrampsId
from _IsPrivate import IsPrivate from _IsPrivate import IsPrivate
from _HasTextMatchingSubstringOf import HasTextMatchingSubstringOf from _HasTextMatchingSubstringOf import HasTextMatchingSubstringOf
from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf

View File

@ -26,8 +26,7 @@ import GrampsWidgets
import RelLib import RelLib
from _SidebarFilter import SidebarFilter from _SidebarFilter import SidebarFilter
from Filters.Rules.Person import * import Filters.Rules
from Filters.Rules.Family import *
from Filters import GenericFamilyFilter, build_filter_model, Rules from Filters import GenericFamilyFilter, build_filter_model, Rules
class FamilySidebarFilter(SidebarFilter): class FamilySidebarFilter(SidebarFilter):