From 5495c3f7053e9d33bb19904167e113eeaebc4756 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Fri, 12 Oct 2007 11:26:28 +0000 Subject: [PATCH] * src/Filters/Rules/Event/_MatchesSourceFilter.py: new filter * src/Filters/Rules/Event/__init__.py: load new filter * src/Filters/Rules/Event/Makefile.am: distribute * src/Filters/Rules/Person/_MatchesEventFilter.py: new filter * src/Filters/Rules/Person/__init__.py: load new filter * src/Filters/Rules/Person/Makefile.am: distribute * po/POTFILES.in: translate new filters This is issue #1249 2007-10-12 Benny Malengier svn: r9160 --- ChangeLog | 10 +++ po/POTFILES.in | 2 + src/Filters/Rules/Event/Makefile.am | 1 + .../Rules/Event/_MatchesSourceFilter.py | 69 ++++++++++++++++++ src/Filters/Rules/Event/__init__.py | 2 + src/Filters/Rules/Person/Makefile.am | 1 + .../Rules/Person/_MatchesEventFilter.py | 72 +++++++++++++++++++ src/Filters/Rules/Person/__init__.py | 2 + 8 files changed, 159 insertions(+) create mode 100644 src/Filters/Rules/Event/_MatchesSourceFilter.py create mode 100644 src/Filters/Rules/Person/_MatchesEventFilter.py diff --git a/ChangeLog b/ChangeLog index b95701990..4d7cfb466 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2007-10-12 Benny Malengier + * src/Filters/Rules/Event/_MatchesSourceFilter.py: new filter + * src/Filters/Rules/Event/__init__.py: load new filter + * src/Filters/Rules/Event/Makefile.am: distribute + * src/Filters/Rules/Person/_MatchesEventFilter.py: new filter + * src/Filters/Rules/Person/__init__.py: load new filter + * src/Filters/Rules/Person/Makefile.am: distribute + * po/POTFILES.in: translate new filters + This is issue #1249 + 2007-10-12 Benny Malengier * src/gen/db/dbdir.py: do name group change from GrampsBSDDB to dbdir. diff --git a/po/POTFILES.in b/po/POTFILES.in index f3022129e..41d1917fc 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -506,6 +506,7 @@ src/Filters/Rules/Person/_IsParentOfFilterMatch.py src/Filters/Rules/Person/_IsSiblingOfFilterMatch.py src/Filters/Rules/Person/_IsSpouseOfFilterMatch.py src/Filters/Rules/Person/_IsWitness.py +src/Filters/Rules/Person/_MatchesEventFilter.py src/Filters/Rules/Person/_MatchesFilter.py src/Filters/Rules/Person/_MatchIdOf.py src/Filters/Rules/Person/_MultipleMarriages.py @@ -562,6 +563,7 @@ src/Filters/Rules/Event/_HasMarkerOf.py src/Filters/Rules/Event/_HasType.py src/Filters/Rules/Event/_HasNoteMatchingSubstringOf.py src/Filters/Rules/Event/_MatchesPersonFilter.py +src/Filters/Rules/Event/_MatchesSourceFilter.py src/Filters/Rules/Event/__init__.py # Filters.Rules.Place package diff --git a/src/Filters/Rules/Event/Makefile.am b/src/Filters/Rules/Event/Makefile.am index 2916385cc..14e99a0b3 100644 --- a/src/Filters/Rules/Event/Makefile.am +++ b/src/Filters/Rules/Event/Makefile.am @@ -14,6 +14,7 @@ pkgdata_PYTHON = \ _HasNoteMatchingSubstringOf.py\ _HasReferenceCountOf.py\ _MatchesPersonFilter.py\ + _MatchesSourceFilter.py\ __init__.py pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Event diff --git a/src/Filters/Rules/Event/_MatchesSourceFilter.py b/src/Filters/Rules/Event/_MatchesSourceFilter.py new file mode 100644 index 000000000..99a9097ea --- /dev/null +++ b/src/Filters/Rules/Event/_MatchesSourceFilter.py @@ -0,0 +1,69 @@ +# +# 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 Filters.Rules._MatchesFilterBase import MatchesFilterBase + +#------------------------------------------------------------------------- +# +# MatchesFilter +# +#------------------------------------------------------------------------- +class MatchesSourceFilter(MatchesFilterBase): + """ + Rule that checks against another filter. + """ + + labels = [_('Source filter name:')] + name = _('Events with source matching the ') + description = _("Matches events with sources that match the " + "specified source filter name") + category = _('General filters') + # we want to have this filter show source filters + namespace = 'Source' + + def prepare(self, db): + MatchesFilterBase.prepare(self, db) + self.MSF_filt = self.find_filter() + + def apply(self, db, event): + if self.MSF_filt is None : + return False + + sourcelist = [x.ref for x in event.get_source_references()] + for sourcehandle in sourcelist: + #check if source in source filter + if self.MSF_filt.check(db, sourcehandle): + return True + return False diff --git a/src/Filters/Rules/Event/__init__.py b/src/Filters/Rules/Event/__init__.py index 4b5b75154..5260d6ee9 100644 --- a/src/Filters/Rules/Event/__init__.py +++ b/src/Filters/Rules/Event/__init__.py @@ -40,6 +40,7 @@ from _HasReferenceCountOf import HasReferenceCountOf from _EventPrivate import EventPrivate from _MatchesFilter import MatchesFilter from _MatchesPersonFilter import MatchesPersonFilter +from _MatchesSourceFilter import MatchesSourceFilter editor_rule_list = [ AllEvents, @@ -54,4 +55,5 @@ editor_rule_list = [ EventPrivate, MatchesFilter, MatchesPersonFilter, + MatchesSourceFilter, ] diff --git a/src/Filters/Rules/Person/Makefile.am b/src/Filters/Rules/Person/Makefile.am index 4d3d27370..a00a87e73 100644 --- a/src/Filters/Rules/Person/Makefile.am +++ b/src/Filters/Rules/Person/Makefile.am @@ -49,6 +49,7 @@ pkgdata_PYTHON = \ _IsSpouseOfFilterMatch.py \ _IsWitness.py \ _MatchesFilter.py \ + _MatchesEventFilter.py \ _MissingParent.py \ _MultipleMarriages.py \ _NeverMarried.py \ diff --git a/src/Filters/Rules/Person/_MatchesEventFilter.py b/src/Filters/Rules/Person/_MatchesEventFilter.py new file mode 100644 index 000000000..fded0cab6 --- /dev/null +++ b/src/Filters/Rules/Person/_MatchesEventFilter.py @@ -0,0 +1,72 @@ +# +# 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: $ + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +import Filters +from Filters.Rules._MatchesFilterBase import MatchesFilterBase + +#------------------------------------------------------------------------- +# +# MatchesFilter +# +#------------------------------------------------------------------------- +class MatchesEventFilter(MatchesFilterBase): + """ + 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 = [_('Event filter name:')] + name = _('Persons with events matching the ') + description = _("Matches persons who have events that match a certain" + " event filter") + category = _('General filters') + # we want to have this filter show event filters + namespace = 'Event' + + def prepare(self, db): + MatchesFilterBase.prepare(self, db) + self.MEF_filt = self.find_filter() + + def apply(self, db, person): + if self.MEF_filt is None : + return False + + eventlist = [x.ref for x in person.get_event_ref_list()] + for eventhandle in eventlist: + #check if event in event filter + if self.MEF_filt.check(db, eventhandle): + return True + return False diff --git a/src/Filters/Rules/Person/__init__.py b/src/Filters/Rules/Person/__init__.py index 029ca39f5..60518e581 100644 --- a/src/Filters/Rules/Person/__init__.py +++ b/src/Filters/Rules/Person/__init__.py @@ -80,6 +80,7 @@ from _IsSiblingOfFilterMatch import IsSiblingOfFilterMatch from _IsSpouseOfFilterMatch import IsSpouseOfFilterMatch from _IsWitness import IsWitness from _MatchesFilter import MatchesFilter +from _MatchesEventFilter import MatchesEventFilter from _MissingParent import MissingParent from _MultipleMarriages import MultipleMarriages from _NeverMarried import NeverMarried @@ -146,6 +147,7 @@ editor_rule_list = [ HasCommonAncestorWith, HasCommonAncestorWithFilterMatch, MatchesFilter, + MatchesEventFilter, MissingParent, IsChildOfFilterMatch, IsParentOfFilterMatch,