From 734b6dff3cc83d0f80a5c1d35841ac85ca822498 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Mon, 27 Aug 2012 09:39:02 +0000 Subject: [PATCH] 6003: Not all sourcebase objects have the same source filter svn: r20271 --- po/POTFILES.in | 10 +++ src/gen/filters/rules/Makefile.am | 1 + src/gen/filters/rules/_hascitationbase.py | 22 ++++-- src/gen/filters/rules/_hassourceofbase.py | 77 +++++++++++++++++++ src/gen/filters/rules/family/Makefile.am | 1 + src/gen/filters/rules/family/__init__.py | 2 + src/gen/filters/rules/family/_hascitation.py | 7 -- src/gen/filters/rules/family/_hassourceof.py | 49 ++++++++++++ src/gen/filters/rules/media/Makefile.am | 4 + src/gen/filters/rules/media/__init__.py | 8 ++ src/gen/filters/rules/media/_hascitation.py | 53 +++++++++++++ .../filters/rules/media/_hassourcecount.py | 47 +++++++++++ src/gen/filters/rules/media/_hassourceof.py | 49 ++++++++++++ .../rules/media/_matchessourceconfidence.py | 46 +++++++++++ src/gen/filters/rules/person/_hascitation.py | 7 -- src/gen/filters/rules/person/_hassourceof.py | 32 +------- src/gen/filters/rules/place/Makefile.am | 4 + src/gen/filters/rules/place/__init__.py | 8 ++ src/gen/filters/rules/place/_hascitation.py | 54 +++++++++++++ .../filters/rules/place/_hassourcecount.py | 47 +++++++++++ src/gen/filters/rules/place/_hassourceof.py | 49 ++++++++++++ .../rules/place/_matchessourceconfidence.py | 46 +++++++++++ 22 files changed, 571 insertions(+), 52 deletions(-) create mode 100644 src/gen/filters/rules/_hassourceofbase.py create mode 100644 src/gen/filters/rules/family/_hassourceof.py create mode 100644 src/gen/filters/rules/media/_hascitation.py create mode 100644 src/gen/filters/rules/media/_hassourcecount.py create mode 100644 src/gen/filters/rules/media/_hassourceof.py create mode 100644 src/gen/filters/rules/media/_matchessourceconfidence.py create mode 100644 src/gen/filters/rules/place/_hascitation.py create mode 100644 src/gen/filters/rules/place/_hassourcecount.py create mode 100644 src/gen/filters/rules/place/_hassourceof.py create mode 100644 src/gen/filters/rules/place/_matchessourceconfidence.py diff --git a/po/POTFILES.in b/po/POTFILES.in index 88fcf6488..9e2f3818e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -31,6 +31,7 @@ src/gen/filters/_filterparser.py # gen.filters.rules package src/gen/filters/rules/_everything.py src/gen/filters/rules/_hasgrampsid.py +src/gen/filters/rules/_hassourceofbase.py src/gen/filters/rules/_hastextmatchingsubstringof.py src/gen/filters/rules/_isprivate.py src/gen/filters/rules/_rule.py @@ -133,6 +134,7 @@ src/gen/filters/rules/family/_hasnotematchingsubstringof.py src/gen/filters/rules/family/_hasnoteregexp.py src/gen/filters/rules/family/_hasreferencecountof.py src/gen/filters/rules/family/_hasreltype.py +src/gen/filters/rules/family/_hassourceof.py src/gen/filters/rules/family/_hassourcecount.py src/gen/filters/rules/family/_hastag.py src/gen/filters/rules/family/_isbookmarked.py @@ -185,6 +187,10 @@ src/gen/filters/rules/place/_matchesfilter.py src/gen/filters/rules/place/_matcheseventfilter.py src/gen/filters/rules/place/_placeprivate.py src/gen/filters/rules/place/_regexpidof.py +src/gen/filters/rules/place/_hassourceof.py +src/gen/filters/rules/place/_matchessourceconfidence.py +src/gen/filters/rules/place/_hassourcecount.py +src/gen/filters/rules/place/_hascitation.py # gen.filters.rules.source package src/gen/filters/rules/source/_allsources.py @@ -233,6 +239,10 @@ src/gen/filters/rules/media/_hastag.py src/gen/filters/rules/media/_matchesfilter.py src/gen/filters/rules/media/_mediaprivate.py src/gen/filters/rules/media/_regexpidof.py +src/gen/filters/rules/media/_hassourcecount.py +src/gen/filters/rules/media/_hassourceof.py +src/gen/filters/rules/media/_matchessourceconfidence.py +src/gen/filters/rules/media/_hascitation.py # gen.filters.rules.repository package src/gen/filters/rules/repository/_allrepos.py diff --git a/src/gen/filters/rules/Makefile.am b/src/gen/filters/rules/Makefile.am index 55ddf08fe..beaa92c3c 100644 --- a/src/gen/filters/rules/Makefile.am +++ b/src/gen/filters/rules/Makefile.am @@ -19,6 +19,7 @@ pkgpython_PYTHON = \ _hasreferencecountbase.py \ _hassourcecountbase.py \ _hassourcebase.py \ + _hassourceofbase.py \ _hastagbase.py \ _hastextmatchingregexpof.py\ _hastextmatchingsubstringof.py\ diff --git a/src/gen/filters/rules/_hascitationbase.py b/src/gen/filters/rules/_hascitationbase.py index 8d0b8fdc6..5a39b1f33 100644 --- a/src/gen/filters/rules/_hascitationbase.py +++ b/src/gen/filters/rules/_hascitationbase.py @@ -47,12 +47,11 @@ class HasCitationBase(Rule): First parameter is [Volume/page, Date, Confidence] """ - - labels = [ 'Volume/Page:', - 'Date:', - 'Confidence:' ] - name = 'Citations matching parameters' - description = "Matches citations with particular parameters" + labels = [ _('Volume/Page:'), + _('Date:'), + _('Confidence:') ] + name = _('Citations matching parameters') + description = _("Matches citations with particular parameters") category = _('Citation/source filters') def prepare(self, db): @@ -63,8 +62,15 @@ class HasCitationBase(Rule): except: pass - def apply(self,db,citation): - if not self.match_substring(0,citation.get_page()): + def apply(self, dbase, object): + for citation_handle in object.get_citation_list(): + citation = dbase.get_citation_from_handle(citation_handle) + if self._apply(dbase, citation): + return True + return False + + def _apply(self, db, citation): + if not self.match_substring(0, citation.get_page()): return False if self.date: diff --git a/src/gen/filters/rules/_hassourceofbase.py b/src/gen/filters/rules/_hassourceofbase.py new file mode 100644 index 000000000..3083435bf --- /dev/null +++ b/src/gen/filters/rules/_hassourceofbase.py @@ -0,0 +1,77 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2002-2006 Donald N. Allingham +# Copyright (C) 2011 Tim G L Lyons +# +# 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: _HasSourceOf.py 18548 2011-12-04 17:09:17Z kulath $ + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gen.ggettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from gen.filters.rules import Rule + +#------------------------------------------------------------------------- +# +# HasSourceOf +# +#------------------------------------------------------------------------- +class HasSourceOfBase(Rule): + """Rule that checks for objects that have a particular source.""" + + labels = [ _('Source ID:') ] + name = _('Object with the ') + category = _('Citation/source filters') + description = _('Matches objects who have a particular source') + + def prepare(self,db): + if self.list[0] == '': + self.source_handle = None + self.nosource = True + return + + self.nosource = False + try: + self.source_handle = db.get_source_from_gramps_id( + self.list[0]).get_handle() + except: + self.source_handle = None + + def apply(self, db, object): + if not self.source_handle: + if self.nosource: + # check whether the citation list is empty as a proxy for + # there being no sources + return len(object.get_all_citation_lists()) == 0 + else: + return False + else: + for citation_handle in object.get_all_citation_lists(): + citation = db.get_citation_from_handle(citation_handle) + if citation.get_reference_handle() == self.source_handle: + return True + return False diff --git a/src/gen/filters/rules/family/Makefile.am b/src/gen/filters/rules/family/Makefile.am index f811bd946..cf08662db 100644 --- a/src/gen/filters/rules/family/Makefile.am +++ b/src/gen/filters/rules/family/Makefile.am @@ -19,6 +19,7 @@ pkgpython_PYTHON = \ _hasreferencecountof.py\ _hasreltype.py\ _hassourcecount.py \ + _hassourceof \ _hastag.py \ __init__.py\ _isbookmarked.py\ diff --git a/src/gen/filters/rules/family/__init__.py b/src/gen/filters/rules/family/__init__.py index 1a72cc094..c50a6a99b 100644 --- a/src/gen/filters/rules/family/__init__.py +++ b/src/gen/filters/rules/family/__init__.py @@ -43,6 +43,7 @@ from _hasnote import HasNote from _hasnoteregexp import HasNoteRegexp from _hasnotematchingsubstringof import HasNoteMatchingSubstringOf from _hassourcecount import HasSourceCount +from _hassourceof import HasSourceOf from _hasreferencecountof import HasReferenceCountOf from _hascitation import HasCitation from _familyprivate import FamilyPrivate @@ -72,6 +73,7 @@ editor_rule_list = [ HasNoteMatchingSubstringOf, HasReferenceCountOf, HasSourceCount, + HasSourceOf, HasCitation, FamilyPrivate, HasEvent, diff --git a/src/gen/filters/rules/family/_hascitation.py b/src/gen/filters/rules/family/_hascitation.py index 6becceb6b..9953b87e9 100644 --- a/src/gen/filters/rules/family/_hascitation.py +++ b/src/gen/filters/rules/family/_hascitation.py @@ -52,10 +52,3 @@ class HasCitation(HasCitationBase): name = _('Family with the ') description = _("Matches families with a citation of a particular " "value") - - def apply(self, dbase, family): - for citation_handle in family.get_citation_list(): - citation = dbase.get_citation_from_handle(citation_handle) - if HasCitationBase.apply(self, dbase, citation): - return True - return False diff --git a/src/gen/filters/rules/family/_hassourceof.py b/src/gen/filters/rules/family/_hassourceof.py new file mode 100644 index 000000000..a117e57ba --- /dev/null +++ b/src/gen/filters/rules/family/_hassourceof.py @@ -0,0 +1,49 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2002-2006 Donald N. Allingham +# Copyright (C) 2011 Tim G L Lyons +# +# 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: _HasSourceOf.py 18548 2011-12-04 17:09:17Z kulath $ + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gen.ggettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from gen.filters.rules._hassourceofbase import HasSourceOfBase + +#------------------------------------------------------------------------- +# +# HasSourceOf +# +#------------------------------------------------------------------------- +class HasSourceOf(HasSourceOfBase): + """Rule that checks family that have a particular source.""" + + labels = [ _('Source ID:') ] + name = _('Families with the ') + category = _('Citation/source filters') + description = _('Matches families who have a particular source') diff --git a/src/gen/filters/rules/media/Makefile.am b/src/gen/filters/rules/media/Makefile.am index 71f445e3f..0e9b42c18 100644 --- a/src/gen/filters/rules/media/Makefile.am +++ b/src/gen/filters/rules/media/Makefile.am @@ -6,13 +6,17 @@ pkgpythondir = $(datadir)/@PACKAGE@/gen/filters/rules/media pkgpython_PYTHON = \ _allmedia.py\ _changedsince.py\ + _hascitation.py \ _hasidof.py\ _hasmedia.py\ _hasnotematchingsubstringof.py\ _hasnoteregexp.py\ _hasreferencecountof.py\ _hastag.py\ + _hassourcecount.py \ + _hassourceof \ _matchesfilter.py\ + _matchessourceconfidence.py\ _mediaprivate.py\ _hasattribute.py\ _regexpidof.py\ diff --git a/src/gen/filters/rules/media/__init__.py b/src/gen/filters/rules/media/__init__.py index bcb988abd..69969ac31 100644 --- a/src/gen/filters/rules/media/__init__.py +++ b/src/gen/filters/rules/media/__init__.py @@ -27,11 +27,15 @@ Package providing filter rules for GRAMPS. from _allmedia import AllMedia from _hasidof import HasIdOf from _regexpidof import RegExpIdOf +from _hascitation import HasCitation from _hasnoteregexp import HasNoteRegexp from _hasnotematchingsubstringof import HasNoteMatchingSubstringOf from _hasreferencecountof import HasReferenceCountOf +from _hassourcecount import HasSourceCount +from _hassourceof import HasSourceOf from _mediaprivate import MediaPrivate from _matchesfilter import MatchesFilter +from _matchessourceconfidence import MatchesSourceConfidence from _hasmedia import HasMedia from _hasattribute import HasAttribute from _changedsince import ChangedSince @@ -39,13 +43,17 @@ from _hastag import HasTag editor_rule_list = [ AllMedia, + HasCitation, HasIdOf, RegExpIdOf, HasNoteRegexp, HasNoteMatchingSubstringOf, HasReferenceCountOf, + HasSourceCount, + HasSourceOf, MediaPrivate, MatchesFilter, + MatchesSourceConfidence, HasAttribute, ChangedSince, HasTag, diff --git a/src/gen/filters/rules/media/_hascitation.py b/src/gen/filters/rules/media/_hascitation.py new file mode 100644 index 000000000..01a546169 --- /dev/null +++ b/src/gen/filters/rules/media/_hascitation.py @@ -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: _HasCitation.py 18548 2011-12-04 17:09:17Z kulath $ + +""" +Filter rule to match persons with a particular citation. +""" +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gen.ggettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from gen.filters.rules._hascitationbase import HasCitationBase + +#------------------------------------------------------------------------- +# +# HasEvent +# +#------------------------------------------------------------------------- +class HasCitation(HasCitationBase): + """Rule that checks for a person with a particular value""" + + labels = [ _('Volume/Page:'), + _('Date:'), + _('Confidence level:')] + name = _('Media with the ') + description = _("Matches media with a citation of a particular " + "value") diff --git a/src/gen/filters/rules/media/_hassourcecount.py b/src/gen/filters/rules/media/_hassourcecount.py new file mode 100644 index 000000000..94a86a24e --- /dev/null +++ b/src/gen/filters/rules/media/_hassourcecount.py @@ -0,0 +1,47 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2002-2007 Donald N. Allingham +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Jerome Rapinat +# Copyright (C) 2008 Benny Malengier +# +# 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: _HasSourceCount.py 18548 2011-12-04 17:09:17Z kulath $ + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gen.ggettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from gen.filters.rules._hassourcecountbase import HasSourceCountBase + +#------------------------------------------------------------------------- +# "People having sources" +#------------------------------------------------------------------------- +class HasSourceCount(HasSourceCountBase): + """Media with sources""" + + name = _('Media with sources') + description = _("Matches media with a certain number of sources connected to it") diff --git a/src/gen/filters/rules/media/_hassourceof.py b/src/gen/filters/rules/media/_hassourceof.py new file mode 100644 index 000000000..16b3fc642 --- /dev/null +++ b/src/gen/filters/rules/media/_hassourceof.py @@ -0,0 +1,49 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2002-2006 Donald N. Allingham +# Copyright (C) 2011 Tim G L Lyons +# +# 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: _HasSourceOf.py 18548 2011-12-04 17:09:17Z kulath $ + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gen.ggettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from gen.filters.rules._hassourceofbase import HasSourceOfBase + +#------------------------------------------------------------------------- +# +# HasSourceOf +# +#------------------------------------------------------------------------- +class HasSourceOf(HasSourceOfBase): + """Rule that checks media that have a particular source.""" + + labels = [ _('Source ID:') ] + name = _('Media with the ') + category = _('Citation/source filters') + description = _('Matches media who have a particular source') diff --git a/src/gen/filters/rules/media/_matchessourceconfidence.py b/src/gen/filters/rules/media/_matchessourceconfidence.py new file mode 100644 index 000000000..7b6851ce5 --- /dev/null +++ b/src/gen/filters/rules/media/_matchessourceconfidence.py @@ -0,0 +1,46 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2011 Jerome Rapinat +# +# 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 +# +# Filters/Rules/Person/_MatchesSourceConfidence.py +# $Id: _MatchesSourceConfidence.py 18361 2011-10-23 03:13:50Z paul-franklin $ +# + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gen.ggettext import sgettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from gen.filters.rules._matchessourceconfidencebase import MatchesSourceConfidenceBase + +#------------------------------------------------------------------------- +# "Confidence level" +#------------------------------------------------------------------------- +class MatchesSourceConfidence(MatchesSourceConfidenceBase): + """Media matching a specific confidence level on its 'direct' source references""" + + labels = [_('Confidence level:')] + name = _('Media with a direct source >= ') + description = _("Matches media with at least one direct source with confidence level(s)") diff --git a/src/gen/filters/rules/person/_hascitation.py b/src/gen/filters/rules/person/_hascitation.py index 6d397a196..1531de14b 100644 --- a/src/gen/filters/rules/person/_hascitation.py +++ b/src/gen/filters/rules/person/_hascitation.py @@ -51,10 +51,3 @@ class HasCitation(HasCitationBase): name = _('People with the ') description = _("Matches people with a citation of a particular " "value") - - def apply(self, dbase, person): - for citation_handle in person.get_citation_list(): - citation = dbase.get_citation_from_handle(citation_handle) - if HasCitationBase.apply(self, dbase, citation): - return True - return False diff --git a/src/gen/filters/rules/person/_hassourceof.py b/src/gen/filters/rules/person/_hassourceof.py index dcfbb8f91..0023444c1 100644 --- a/src/gen/filters/rules/person/_hassourceof.py +++ b/src/gen/filters/rules/person/_hassourceof.py @@ -33,45 +33,17 @@ from gen.ggettext import gettext as _ # GRAMPS modules # #------------------------------------------------------------------------- -from gen.filters.rules import Rule +from gen.filters.rules._hassourceofbase import HasSourceOfBase #------------------------------------------------------------------------- # # HasSourceOf # #------------------------------------------------------------------------- -class HasSourceOf(Rule): +class HasSourceOf(HasSourceOfBase): """Rule that checks people that have a particular source.""" labels = [ _('Source ID:') ] name = _('People with the ') category = _('Citation/source filters') description = _('Matches people who have a particular source') - - def prepare(self,db): - if self.list[0] == '': - self.source_handle = None - self.nosource = True - return - - self.nosource = False - try: - self.source_handle = db.get_source_from_gramps_id( - self.list[0]).get_handle() - except: - self.source_handle = None - - def apply(self, db, person): - if not self.source_handle: - if self.nosource: - # check whether the citation list is empty as a proxy for - # there being no sources - return len(person.get_all_citation_lists()) == 0 - else: - return False - else: - for citation_handle in person.get_all_citation_lists(): - citation = db.get_citation_from_handle(citation_handle) - if citation.get_reference_handle() == self.source_handle: - return True - return False diff --git a/src/gen/filters/rules/place/Makefile.am b/src/gen/filters/rules/place/Makefile.am index a05db522c..1256eaa36 100644 --- a/src/gen/filters/rules/place/Makefile.am +++ b/src/gen/filters/rules/place/Makefile.am @@ -6,6 +6,7 @@ pkgpythondir = $(datadir)/@PACKAGE@/gen/filters/rules/place pkgpython_PYTHON = \ _allplaces.py\ _changedsince.py\ + _hascitation.py \ _hasidof.py\ _hasnolatorlon.py\ _inlatlonneighborhood.py\ @@ -15,8 +16,11 @@ pkgpython_PYTHON = \ _hasplace.py\ _hasnote.py \ _hasreferencecountof.py\ + _hassourcecount.py \ + _hassourceof \ _matchesfilter.py\ _matcheseventfilter.py\ + _matchessourceconfidence.py\ _placeprivate.py\ _regexpidof.py\ __init__.py diff --git a/src/gen/filters/rules/place/__init__.py b/src/gen/filters/rules/place/__init__.py index a427ee0b0..3bcaf0b88 100644 --- a/src/gen/filters/rules/place/__init__.py +++ b/src/gen/filters/rules/place/__init__.py @@ -26,6 +26,7 @@ Package providing filter rules for GRAMPS. """ from _allplaces import AllPlaces +from _hascitation import HasCitation from _hasgallery import HasGallery from _hasidof import HasIdOf from _regexpidof import RegExpIdOf @@ -33,16 +34,20 @@ from _hasnote import HasNote from _hasnoteregexp import HasNoteRegexp from _hasnotematchingsubstringof import HasNoteMatchingSubstringOf from _hasreferencecountof import HasReferenceCountOf +from _hassourcecount import HasSourceCount +from _hassourceof import HasSourceOf from _placeprivate import PlacePrivate from _matchesfilter import MatchesFilter from _hasplace import HasPlace from _hasnolatorlon import HasNoLatOrLon from _inlatlonneighborhood import InLatLonNeighborhood from _matcheseventfilter import MatchesEventFilter +from _matchessourceconfidence import MatchesSourceConfidence from _changedsince import ChangedSince editor_rule_list = [ AllPlaces, + HasCitation, HasGallery, HasIdOf, RegExpIdOf, @@ -50,8 +55,11 @@ editor_rule_list = [ HasNoteRegexp, HasNoteMatchingSubstringOf, HasReferenceCountOf, + HasSourceCount, + HasSourceOf, PlacePrivate, MatchesFilter, + MatchesSourceConfidence, HasPlace, HasNoLatOrLon, InLatLonNeighborhood, diff --git a/src/gen/filters/rules/place/_hascitation.py b/src/gen/filters/rules/place/_hascitation.py new file mode 100644 index 000000000..cf38b1e9d --- /dev/null +++ b/src/gen/filters/rules/place/_hascitation.py @@ -0,0 +1,54 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2002-2006 Donald N. Allingham +# Copyright (C) 2011 Tim G L Lyons +# +# 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: _HasCitation.py 18548 2011-12-04 17:09:17Z kulath $ + +""" +Filter rule to match family with a particular citation. +""" +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gen.ggettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from gen.filters.rules._hascitationbase import HasCitationBase + +#------------------------------------------------------------------------- +# +# HasEvent +# +#------------------------------------------------------------------------- +class HasCitation(HasCitationBase): + """Rule that checks for a family with a particular value""" + + labels = [ _('Volume/Page:'), + _('Date:'), + _('Confidence level:')] + name = _('Place with the ') + description = _("Matches places with a citation of a particular " + "value") diff --git a/src/gen/filters/rules/place/_hassourcecount.py b/src/gen/filters/rules/place/_hassourcecount.py new file mode 100644 index 000000000..14548a37c --- /dev/null +++ b/src/gen/filters/rules/place/_hassourcecount.py @@ -0,0 +1,47 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2002-2007 Donald N. Allingham +# Copyright (C) 2007-2008 Brian G. Matherly +# Copyright (C) 2008 Jerome Rapinat +# Copyright (C) 2008 Benny Malengier +# +# 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: _HasSourceCount.py 18548 2011-12-04 17:09:17Z kulath $ + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gen.ggettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from gen.filters.rules._hassourcecountbase import HasSourceCountBase + +#------------------------------------------------------------------------- +# "People having sources" +#------------------------------------------------------------------------- +class HasSourceCount(HasSourceCountBase): + """Place with sources""" + + name = _('Place with sources') + description = _("Matches places with a certain number of sources connected to it") diff --git a/src/gen/filters/rules/place/_hassourceof.py b/src/gen/filters/rules/place/_hassourceof.py new file mode 100644 index 000000000..5fdff8ff7 --- /dev/null +++ b/src/gen/filters/rules/place/_hassourceof.py @@ -0,0 +1,49 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2002-2006 Donald N. Allingham +# Copyright (C) 2011 Tim G L Lyons +# +# 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: _HasSourceOf.py 18548 2011-12-04 17:09:17Z kulath $ + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gen.ggettext import gettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from gen.filters.rules._hassourceofbase import HasSourceOfBase + +#------------------------------------------------------------------------- +# +# HasSourceOf +# +#------------------------------------------------------------------------- +class HasSourceOf(HasSourceOfBase): + """Rule that checks family that have a particular source.""" + + labels = [ _('Source ID:') ] + name = _('Places with the ') + category = _('Citation/source filters') + description = _('Matches places who have a particular source') diff --git a/src/gen/filters/rules/place/_matchessourceconfidence.py b/src/gen/filters/rules/place/_matchessourceconfidence.py new file mode 100644 index 000000000..bb1999278 --- /dev/null +++ b/src/gen/filters/rules/place/_matchessourceconfidence.py @@ -0,0 +1,46 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2011 Jerome Rapinat +# +# 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 +# +# Filters/Rules/Person/_MatchesSourceConfidence.py +# $Id: _MatchesSourceConfidence.py 18361 2011-10-23 03:13:50Z paul-franklin $ +# + +#------------------------------------------------------------------------- +# +# Standard Python modules +# +#------------------------------------------------------------------------- +from gen.ggettext import sgettext as _ + +#------------------------------------------------------------------------- +# +# GRAMPS modules +# +#------------------------------------------------------------------------- +from gen.filters.rules._matchessourceconfidencebase import MatchesSourceConfidenceBase + +#------------------------------------------------------------------------- +# "Confidence level" +#------------------------------------------------------------------------- +class MatchesSourceConfidence(MatchesSourceConfidenceBase): + """Media matching a specific confidence level on its 'direct' source references""" + + labels = [_('Confidence level:')] + name = _('Place with a direct source >= ') + description = _("Matches places with at least one direct source with confidence level(s)")