From edc1603dc36591445b9a632670fc8967027da2de Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 12 Jul 2006 19:20:54 +0000 Subject: [PATCH] 2006-07-12 Don Allingham * 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 --- gramps2/ChangeLog | 17 ++++++ .../src/Filters/Rules/Family/_AllFamilies.py | 47 +++++++++++++++ gramps2/src/Filters/Rules/Family/_HasIdOf.py | 49 +++++++++++++++ .../Family/_HasNoteMatchingSubstringOf.py | 45 ++++++++++++++ .../Filters/Rules/Family/_HasNoteRegexp.py | 46 ++++++++++++++ .../src/Filters/Rules/Family/_RegExpIdOf.py | 48 +++++++++++++++ gramps2/src/Filters/Rules/Family/__init__.py | 10 ++++ gramps2/src/Filters/Rules/Person/_HasIdOf.py | 6 +- .../Filters/Rules/Person/_HasNoteRegexp.py | 19 +----- gramps2/src/Filters/Rules/Person/__init__.py | 2 +- gramps2/src/Filters/Rules/_HasGrampsId.py | 48 +++++++++++++++ .../src/Filters/Rules/_HasNoteRegexBase.py | 60 +++++++++++++++++++ .../src/Filters/Rules/_HasNoteSubstrBase.py | 52 ++++++++++++++++ gramps2/src/Filters/Rules/_RegExpIdBase.py | 60 +++++++++++++++++++ gramps2/src/Filters/Rules/__init__.py | 1 + gramps2/src/Filters/_FamilySidebarFilter.py | 3 +- 16 files changed, 489 insertions(+), 24 deletions(-) create mode 100644 gramps2/src/Filters/Rules/Family/_AllFamilies.py create mode 100644 gramps2/src/Filters/Rules/Family/_HasIdOf.py create mode 100644 gramps2/src/Filters/Rules/Family/_HasNoteMatchingSubstringOf.py create mode 100644 gramps2/src/Filters/Rules/Family/_HasNoteRegexp.py create mode 100644 gramps2/src/Filters/Rules/Family/_RegExpIdOf.py create mode 100644 gramps2/src/Filters/Rules/_HasGrampsId.py create mode 100644 gramps2/src/Filters/Rules/_HasNoteRegexBase.py create mode 100644 gramps2/src/Filters/Rules/_HasNoteSubstrBase.py create mode 100644 gramps2/src/Filters/Rules/_RegExpIdBase.py diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index faf97ab11..6e5aeb5fc 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,3 +1,20 @@ +2006-07-12 Don Allingham + * 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 * po/gramps.pot: remove autogenerated file * src/ViewManager.py: fix default state of filter menu item diff --git a/gramps2/src/Filters/Rules/Family/_AllFamilies.py b/gramps2/src/Filters/Rules/Family/_AllFamilies.py new file mode 100644 index 000000000..cefabfa33 --- /dev/null +++ b/gramps2/src/Filters/Rules/Family/_AllFamilies.py @@ -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') + diff --git a/gramps2/src/Filters/Rules/Family/_HasIdOf.py b/gramps2/src/Filters/Rules/Family/_HasIdOf.py new file mode 100644 index 000000000..11c2448e1 --- /dev/null +++ b/gramps2/src/Filters/Rules/Family/_HasIdOf.py @@ -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 ') + description = _("Matches a family with a specified GRAMPS ID") + category = _('General filters') + diff --git a/gramps2/src/Filters/Rules/Family/_HasNoteMatchingSubstringOf.py b/gramps2/src/Filters/Rules/Family/_HasNoteMatchingSubstringOf.py new file mode 100644 index 000000000..0c562e73c --- /dev/null +++ b/gramps2/src/Filters/Rules/Family/_HasNoteMatchingSubstringOf.py @@ -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 """ + + name = _('Families having notes containing ') + description = _("Matches families whose notes contain text matching a substring") + diff --git a/gramps2/src/Filters/Rules/Family/_HasNoteRegexp.py b/gramps2/src/Filters/Rules/Family/_HasNoteRegexp.py new file mode 100644 index 000000000..58405d565 --- /dev/null +++ b/gramps2/src/Filters/Rules/Family/_HasNoteRegexp.py @@ -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 ') + description = _("Matches families whose notes contain text " + "matching a regular expression") + diff --git a/gramps2/src/Filters/Rules/Family/_RegExpIdOf.py b/gramps2/src/Filters/Rules/Family/_RegExpIdOf.py new file mode 100644 index 000000000..a789ebb12 --- /dev/null +++ b/gramps2/src/Filters/Rules/Family/_RegExpIdOf.py @@ -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 ') + description = _("Matches families with a GRAMPS ID that contains the regular expression") + diff --git a/gramps2/src/Filters/Rules/Family/__init__.py b/gramps2/src/Filters/Rules/Family/__init__.py index 4a558bb8b..47a15ee27 100644 --- a/gramps2/src/Filters/Rules/Family/__init__.py +++ b/gramps2/src/Filters/Rules/Family/__init__.py @@ -27,7 +27,17 @@ Package providing filter rules for GRAMPS. __author__ = "Don Allingham" 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 = [ + AllFamilies, HasRelType, + HasIdOf, + RegExpIdOf, + HasNoteRegexp, + HasNoteMatchingSubstringOf, ] diff --git a/gramps2/src/Filters/Rules/Person/_HasIdOf.py b/gramps2/src/Filters/Rules/Person/_HasIdOf.py index e0027661a..f3ca7bb4a 100644 --- a/gramps2/src/Filters/Rules/Person/_HasIdOf.py +++ b/gramps2/src/Filters/Rules/Person/_HasIdOf.py @@ -32,14 +32,14 @@ from gettext import gettext as _ # GRAMPS modules # #------------------------------------------------------------------------- -from Filters.Rules._Rule import Rule +from Filters.Rules import HasGrampsId #------------------------------------------------------------------------- # # HasIdOf # #------------------------------------------------------------------------- -class HasIdOf(Rule): +class HasIdOf(HasGrampsId): """Rule that checks for a person with a specific GRAMPS ID""" labels = [ _('ID:') ] @@ -47,5 +47,3 @@ class HasIdOf(Rule): description = _("Matches people with a specified GRAMPS ID") category = _('General filters') - def apply(self,db,person): - return person.gramps_id == self.list[0] diff --git a/gramps2/src/Filters/Rules/Person/_HasNoteRegexp.py b/gramps2/src/Filters/Rules/Person/_HasNoteRegexp.py index 0fd316b2b..56b28f779 100644 --- a/gramps2/src/Filters/Rules/Person/_HasNoteRegexp.py +++ b/gramps2/src/Filters/Rules/Person/_HasNoteRegexp.py @@ -25,7 +25,6 @@ # Standard Python modules # #------------------------------------------------------------------------- -import re from gettext import gettext as _ #------------------------------------------------------------------------- @@ -33,28 +32,14 @@ from gettext import gettext as _ # GRAMPS modules # #------------------------------------------------------------------------- -from Filters.Rules._Rule import Rule +from Filters.Rules._HasNoteRegexBase import HasNoteRegexBase #------------------------------------------------------------------------- # "People having notes that contain a substring" #------------------------------------------------------------------------- -class HasNoteRegexp(Rule): - """People having notes containing """ +class HasNoteRegexp(HasNoteRegexBase): - labels = [ _('Regular expression:')] name = _('People having notes containing ') description = _("Matches people 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 diff --git a/gramps2/src/Filters/Rules/Person/__init__.py b/gramps2/src/Filters/Rules/Person/__init__.py index d39159072..c68234e9e 100644 --- a/gramps2/src/Filters/Rules/Person/__init__.py +++ b/gramps2/src/Filters/Rules/Person/__init__.py @@ -150,5 +150,5 @@ editor_rule_list = [ RelationshipPathBetweenBookmarks, HasTextMatchingSubstringOf, HasNote, - HasNoteMatchingSubstringOf + HasNoteRegexp, ] diff --git a/gramps2/src/Filters/Rules/_HasGrampsId.py b/gramps2/src/Filters/Rules/_HasGrampsId.py new file mode 100644 index 000000000..1a44ee90a --- /dev/null +++ b/gramps2/src/Filters/Rules/_HasGrampsId.py @@ -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 ') + description = _("Matches objects with a specified GRAMPS ID") + category = _('General filters') diff --git a/gramps2/src/Filters/Rules/_HasNoteRegexBase.py b/gramps2/src/Filters/Rules/_HasNoteRegexBase.py new file mode 100644 index 000000000..2159d7385 --- /dev/null +++ b/gramps2/src/Filters/Rules/_HasNoteRegexBase.py @@ -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 """ + + labels = [ _('Regular expression:')] + name = _('Objects having notes containing ') + 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 diff --git a/gramps2/src/Filters/Rules/_HasNoteSubstrBase.py b/gramps2/src/Filters/Rules/_HasNoteSubstrBase.py new file mode 100644 index 000000000..9123abb32 --- /dev/null +++ b/gramps2/src/Filters/Rules/_HasNoteSubstrBase.py @@ -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 """ + + labels = [ _('Substring:')] + name = _('Objects having notes containing ') + 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 diff --git a/gramps2/src/Filters/Rules/_RegExpIdBase.py b/gramps2/src/Filters/Rules/_RegExpIdBase.py new file mode 100644 index 000000000..bd683ba4e --- /dev/null +++ b/gramps2/src/Filters/Rules/_RegExpIdBase.py @@ -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 ') + 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 diff --git a/gramps2/src/Filters/Rules/__init__.py b/gramps2/src/Filters/Rules/__init__.py index ad7ed8f01..05150121e 100644 --- a/gramps2/src/Filters/Rules/__init__.py +++ b/gramps2/src/Filters/Rules/__init__.py @@ -27,6 +27,7 @@ Package providing filter rules for GRAMPS. __author__ = "Don Allingham" from _Everything import Everything +from _HasGrampsId import HasGrampsId from _IsPrivate import IsPrivate from _HasTextMatchingSubstringOf import HasTextMatchingSubstringOf from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf diff --git a/gramps2/src/Filters/_FamilySidebarFilter.py b/gramps2/src/Filters/_FamilySidebarFilter.py index c9ddb2e31..d858a1b1c 100644 --- a/gramps2/src/Filters/_FamilySidebarFilter.py +++ b/gramps2/src/Filters/_FamilySidebarFilter.py @@ -26,8 +26,7 @@ import GrampsWidgets import RelLib from _SidebarFilter import SidebarFilter -from Filters.Rules.Person import * -from Filters.Rules.Family import * +import Filters.Rules from Filters import GenericFamilyFilter, build_filter_model, Rules class FamilySidebarFilter(SidebarFilter):