From 5935a315b2077abcf2685f31b215866bd3277702 Mon Sep 17 00:00:00 2001 From: Matthias Kemmer Date: Sat, 1 Jun 2019 23:04:15 +0200 Subject: [PATCH] Add 'HasAttribute' filter rule to repositories, sources and citations Fixes #9845 --- gramps/gen/filters/rules/citation/__init__.py | 2 + .../filters/rules/citation/_hasattribute.py | 49 +++++++++++++++++++ .../gen/filters/rules/repository/__init__.py | 2 + .../filters/rules/repository/_hasattribute.py | 49 +++++++++++++++++++ gramps/gen/filters/rules/source/__init__.py | 2 + .../gen/filters/rules/source/_hasattribute.py | 49 +++++++++++++++++++ po/POTFILES.in | 3 ++ 7 files changed, 156 insertions(+) create mode 100644 gramps/gen/filters/rules/citation/_hasattribute.py create mode 100644 gramps/gen/filters/rules/repository/_hasattribute.py create mode 100644 gramps/gen/filters/rules/source/_hasattribute.py diff --git a/gramps/gen/filters/rules/citation/__init__.py b/gramps/gen/filters/rules/citation/__init__.py index a5537a7e7..63185d09f 100644 --- a/gramps/gen/filters/rules/citation/__init__.py +++ b/gramps/gen/filters/rules/citation/__init__.py @@ -28,6 +28,7 @@ from ._hascitation import HasCitation from ._allcitations import AllCitations from ._changedsince import ChangedSince from ._citationprivate import CitationPrivate +from ._hasattribute import HasAttribute from ._hasgallery import HasGallery from ._hasidof import HasIdOf from ._hasnote import HasNote @@ -50,6 +51,7 @@ editor_rule_list = [ AllCitations, ChangedSince, CitationPrivate, + HasAttribute, HasGallery, HasIdOf, HasNote, diff --git a/gramps/gen/filters/rules/citation/_hasattribute.py b/gramps/gen/filters/rules/citation/_hasattribute.py new file mode 100644 index 000000000..f15c2be64 --- /dev/null +++ b/gramps/gen/filters/rules/citation/_hasattribute.py @@ -0,0 +1,49 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2008 Gary Burton +# Copyright (C) 2019 Matthias Kemmer +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +# ------------------------------------------------------------------------- +# +# Standard Python modules +# +# ------------------------------------------------------------------------- +from ....const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext + +# ------------------------------------------------------------------------- +# +# Gramps modules +# +# ------------------------------------------------------------------------- +from .._hasattributebase import HasAttributeBase + + +# ------------------------------------------------------------------------- +# +# HasAttribute +# +# ------------------------------------------------------------------------- +class HasAttribute(HasAttributeBase): + """Rule that checks for a citation with a particular attribute""" + + labels = [_('Citation attribute:'), _('Value:')] + name = _('Citations with the attribute ') + description = _("Matches citations with the attribute " + "of a particular value") diff --git a/gramps/gen/filters/rules/repository/__init__.py b/gramps/gen/filters/rules/repository/__init__.py index 71b26030b..8e3a3c536 100644 --- a/gramps/gen/filters/rules/repository/__init__.py +++ b/gramps/gen/filters/rules/repository/__init__.py @@ -25,6 +25,7 @@ Package providing filter rules for Gramps. from ._allrepos import AllRepos from ._hasidof import HasIdOf from ._regexpidof import RegExpIdOf +from ._hasattribute import HasAttribute from ._hasnoteregexp import HasNoteRegexp from ._hasnotematchingsubstringof import HasNoteMatchingSubstringOf from ._hasreferencecountof import HasReferenceCountOf @@ -37,6 +38,7 @@ from ._hastag import HasTag editor_rule_list = [ AllRepos, + HasAttribute, HasIdOf, RegExpIdOf, HasNoteRegexp, diff --git a/gramps/gen/filters/rules/repository/_hasattribute.py b/gramps/gen/filters/rules/repository/_hasattribute.py new file mode 100644 index 000000000..875356c6b --- /dev/null +++ b/gramps/gen/filters/rules/repository/_hasattribute.py @@ -0,0 +1,49 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2008 Gary Burton +# Copyright (C) 2019 Matthias Kemmer +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +# ------------------------------------------------------------------------- +# +# Standard Python modules +# +# ------------------------------------------------------------------------- +from ....const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext + +# ------------------------------------------------------------------------- +# +# Gramps modules +# +# ------------------------------------------------------------------------- +from .._hasattributebase import HasAttributeBase + + +# ------------------------------------------------------------------------- +# +# HasAttribute +# +# ------------------------------------------------------------------------- +class HasAttribute(HasAttributeBase): + """Rule that checks for a repository with a particular attribute""" + + labels = [_('Repository attribute:'), _('Value:')] + name = _('Repositories with the attribute ') + description = _("Matches repositories with the attribute " + "of a particular value") diff --git a/gramps/gen/filters/rules/source/__init__.py b/gramps/gen/filters/rules/source/__init__.py index 38b6d2f9b..83184cccd 100644 --- a/gramps/gen/filters/rules/source/__init__.py +++ b/gramps/gen/filters/rules/source/__init__.py @@ -27,6 +27,7 @@ Package providing filter rules for Gramps. from .._hassourcebase import HasSourceBase as HasSource from ._allsources import AllSources +from ._hasattribute import HasAttribute from ._hasgallery import HasGallery from ._hasidof import HasIdOf from ._regexpidof import RegExpIdOf @@ -45,6 +46,7 @@ from ._hastag import HasTag editor_rule_list = [ AllSources, + HasAttribute, HasGallery, HasIdOf, RegExpIdOf, diff --git a/gramps/gen/filters/rules/source/_hasattribute.py b/gramps/gen/filters/rules/source/_hasattribute.py new file mode 100644 index 000000000..f9bb0c675 --- /dev/null +++ b/gramps/gen/filters/rules/source/_hasattribute.py @@ -0,0 +1,49 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2008 Gary Burton +# Copyright (C) 2019 Matthias Kemmer +# +# 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +# ------------------------------------------------------------------------- +# +# Standard Python modules +# +# ------------------------------------------------------------------------- +from ....const import GRAMPS_LOCALE as glocale +_ = glocale.translation.gettext + +# ------------------------------------------------------------------------- +# +# Gramps modules +# +# ------------------------------------------------------------------------- +from .._hasattributebase import HasAttributeBase + + +# ------------------------------------------------------------------------- +# +# HasAttribute +# +# ------------------------------------------------------------------------- +class HasAttribute(HasAttributeBase): + """Rule that checks for a source with a particular attribute""" + + labels = [_('Source attribute:'), _('Value:')] + name = _('Sources with the attribute ') + description = _("Matches sources with the attribute " + "of a particular value") diff --git a/po/POTFILES.in b/po/POTFILES.in index 0801ce93e..32c61a125 100755 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -47,6 +47,7 @@ gramps/gen/filters/rules/_rule.py gramps/gen/filters/rules/citation/_allcitations.py gramps/gen/filters/rules/citation/_changedsince.py gramps/gen/filters/rules/citation/_citationprivate.py +gramps/gen/filters/rules/citation/_hasattribute.py gramps/gen/filters/rules/citation/_hascitation.py gramps/gen/filters/rules/citation/_hasgallery.py gramps/gen/filters/rules/citation/_hasidof.py @@ -254,6 +255,7 @@ gramps/gen/filters/rules/place/_regexpidof.py gramps/gen/filters/rules/place/_withinarea.py gramps/gen/filters/rules/repository/_allrepos.py gramps/gen/filters/rules/repository/_changedsince.py +gramps/gen/filters/rules/repository/_hasattribute.py gramps/gen/filters/rules/repository/_hasidof.py gramps/gen/filters/rules/repository/_hasnotematchingsubstringof.py gramps/gen/filters/rules/repository/_hasnoteregexp.py @@ -266,6 +268,7 @@ gramps/gen/filters/rules/repository/_regexpidof.py gramps/gen/filters/rules/repository/_repoprivate.py gramps/gen/filters/rules/source/_allsources.py gramps/gen/filters/rules/source/_changedsince.py +gramps/gen/filters/rules/source/_hasattribute.py gramps/gen/filters/rules/source/_hasgallery.py gramps/gen/filters/rules/source/_hasidof.py gramps/gen/filters/rules/source/_hasnote.py