Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gramps/gen/filters/_filterparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ def __upgrade(self):
"Has the personal event": rules.person.HasEvent,
"Has the family event": rules.person.HasFamilyEvent,
"Has the personal attribute": rules.person.HasAttribute,
"Has not the personal attribute": rules.person.HasNotAttribute,
"Has the family attribute": rules.person.HasFamilyAttribute,
"Has source of": rules.person.HasSourceOf,
"Matches the filter named": rules.person.HasSourceOf,
Expand Down
1 change: 1 addition & 0 deletions gramps/gen/filters/rules/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
Match on sub-objects
_ChangedSinceBase Object changed since date
_HasAttributeBase Object has particular attribute value
_HasNotAttributeBase
_HasGrampsId Object has a specific Gramps Id
_HasNoteRegexBase Object has notes matching regular expression
_HasNoteSubstrBase Object has note containing substring
Expand Down
82 changes: 82 additions & 0 deletions gramps/gen/filters/rules/_hasnotattributebase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2002-2006 Donald N. Allingham
# 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, see <https://www.gnu.org/licenses/>.
#

"""
Rule that checks for an object with a particular attribute.
"""

# -------------------------------------------------------------------------
#
# Gramps modules
#
# -------------------------------------------------------------------------
from ...const import GRAMPS_LOCALE as glocale
from ...lib.attrtype import AttributeType
from . import Rule

_ = glocale.translation.gettext


# -------------------------------------------------------------------------
#
# Typing modules
#
# -------------------------------------------------------------------------
from ...lib.attrbase import AttributeBase
from ...db import Database


# -------------------------------------------------------------------------
#
# HasNotAttributeBase
#
# -------------------------------------------------------------------------
class HasNotAttributeBase(Rule):
"""
Rule that checks for an object without a particular attribute.
"""

name = "Objects without the <attribute>"
description = "Matches objects without the given attribute"
category = _("General filters")
allow_regex = True

def __init__(self, arg, use_regex=False, use_case=False):
super().__init__(arg, use_regex, use_case)
self.attribute_type = None

def prepare(self, db: Database, user):
"""
Prepare the rule. Things that should only be done once.
"""
if self.list[0]:
self.attribute_type = AttributeType()
self.attribute_type.set_from_xml_str(self.list[0])

def apply_to_one(self, db: Database, obj: AttributeBase) -> bool:
"""
Apply the rule. Return True if a match.
"""
if self.attribute_type:
for attribute in obj.attribute_list:
name_match = attribute.type == self.attribute_type
if name_match:
return False
return True
2 changes: 2 additions & 0 deletions gramps/gen/filters/rules/citation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from ._changedsince import ChangedSince
from ._citationprivate import CitationPrivate
from ._hasattribute import HasAttribute
from ._hasnotattribute import HasNotAttribute
from ._hasgallery import HasGallery
from ._hasidof import HasIdOf
from ._hasnote import HasNote
Expand Down Expand Up @@ -55,6 +56,7 @@
HasAttribute,
HasGallery,
HasIdOf,
HasNotAttribute,
HasNote,
HasNoteRegexp,
HasNoteTag,
Expand Down
47 changes: 47 additions & 0 deletions gramps/gen/filters/rules/citation/_hasnotattribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2026 Thierry Vignaud
#
# 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, see <https://www.gnu.org/licenses/>.
#

# -------------------------------------------------------------------------
#
# Standard Python modules
#
# -------------------------------------------------------------------------
from ....const import GRAMPS_LOCALE as glocale

_ = glocale.translation.gettext

# -------------------------------------------------------------------------
#
# Gramps modules
#
# -------------------------------------------------------------------------
from .._hasnotattributebase import HasNotAttributeBase


# -------------------------------------------------------------------------
#
# HasNotAttribute
#
# -------------------------------------------------------------------------
class HasNotAttribute(HasNotAttributeBase):
"""Rule that checks for a citation with a particular attribute"""

labels = [_("Citation attribute:")]
name = _("Citations without the attribute <attribute>")
description = _("Matches citations without the attribute")
2 changes: 2 additions & 0 deletions gramps/gen/filters/rules/event/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
from ._matchessourceconfidence import MatchesSourceConfidence
from ._matchessourcefilter import MatchesSourceFilter
from ._hasattribute import HasAttribute
from ._hasnotattribute import HasNotAttribute
from ._hasdata import HasData
from ._changedsince import ChangedSince
from ._hastag import HasTag
Expand All @@ -68,6 +69,7 @@
MatchesSourceConfidence,
MatchesSourceFilter,
HasAttribute,
HasNotAttribute,
HasData,
ChangedSince,
HasTag,
Expand Down
47 changes: 47 additions & 0 deletions gramps/gen/filters/rules/event/_hasnotattribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2026 Thierry Vignaud
#
# 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, see <https://www.gnu.org/licenses/>.
#

# -------------------------------------------------------------------------
#
# Standard Python modules
#
# -------------------------------------------------------------------------
from ....const import GRAMPS_LOCALE as glocale

_ = glocale.translation.gettext

# -------------------------------------------------------------------------
#
# Gramps modules
#
# -------------------------------------------------------------------------
from .._hasnotattributebase import HasNotAttributeBase


# -------------------------------------------------------------------------
#
# HasNotAttribute
#
# -------------------------------------------------------------------------
class HasNotAttribute(HasNotAttributeBase):
"""Rule that checks for an event with a particular event attribute"""

labels = [_("Event attribute:")]
name = _("Events without the attribute <attribute>")
description = _("Matches events without the event attribute")
2 changes: 2 additions & 0 deletions gramps/gen/filters/rules/family/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
from ._hascitation import HasCitation
from ._familyprivate import FamilyPrivate
from ._hasattribute import HasAttribute
from ._hasnotattribute import HasNotAttribute
from ._hasevent import HasEvent
from ._isbookmarked import IsBookmarked
from ._matchesfilter import MatchesFilter
Expand Down Expand Up @@ -81,6 +82,7 @@
FamilyPrivate,
HasEvent,
HasAttribute,
HasNotAttribute,
IsBookmarked,
MatchesFilter,
MatchesSourceConfidence,
Expand Down
47 changes: 47 additions & 0 deletions gramps/gen/filters/rules/family/_hasnotattribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2026 Thierry Vignaud
#
# 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, see <https://www.gnu.org/licenses/>.
#

# -------------------------------------------------------------------------
#
# Standard Python modules
#
# -------------------------------------------------------------------------
from ....const import GRAMPS_LOCALE as glocale

_ = glocale.translation.gettext

# -------------------------------------------------------------------------
#
# Gramps modules
#
# -------------------------------------------------------------------------
from .._hasnotattributebase import HasNotAttributeBase


# -------------------------------------------------------------------------
#
# HasNotAttribute
#
# -------------------------------------------------------------------------
class HasNotAttribute(HasNotAttributeBase):
"""Rule that checks for a family with a particular family attribute"""

labels = [_("Family attribute:")]
name = _("Families without the family <attribute>")
description = _("Matches families without the family attribute")
2 changes: 2 additions & 0 deletions gramps/gen/filters/rules/media/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
from ._matchessourceconfidence import MatchesSourceConfidence
from ._hasmedia import HasMedia
from ._hasattribute import HasAttribute
from ._hasnotattribute import HasNotAttribute
from ._changedsince import ChangedSince
from ._hastag import HasTag

Expand All @@ -56,6 +57,7 @@
MatchesSourceConfidence,
HasMedia,
HasAttribute,
HasNotAttribute,
ChangedSince,
HasTag,
]
47 changes: 47 additions & 0 deletions gramps/gen/filters/rules/media/_hasnotattribute.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2026 Thierry Vignaud
#
# 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, see <https://www.gnu.org/licenses/>.
#

# -------------------------------------------------------------------------
#
# Standard Python modules
#
# -------------------------------------------------------------------------
from ....const import GRAMPS_LOCALE as glocale

_ = glocale.translation.gettext

# -------------------------------------------------------------------------
#
# Gramps modules
#
# -------------------------------------------------------------------------
from .._hasnotattributebase import HasNotAttributeBase


# -------------------------------------------------------------------------
#
# HasNotAttribute
#
# -------------------------------------------------------------------------
class HasNotAttribute(HasNotAttributeBase):
"""Rule that checks for a media object with a particular attribute"""

labels = [_("Media attribute:")]
name = _("Media objects without the attribute <attribute>")
description = _("Matches media objects without the attribute")
2 changes: 2 additions & 0 deletions gramps/gen/filters/rules/person/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
from ._hasalternatename import HasAlternateName
from ._hasassociation import HasAssociation
from ._hasattribute import HasAttribute
from ._hasnotattribute import HasNotAttribute
from ._hasbirth import HasBirth
from ._hascitation import HasCitation
from ._hascommonancestorwith import HasCommonAncestorWith
Expand Down Expand Up @@ -142,6 +143,7 @@
HasEvent,
HasFamilyEvent,
HasAttribute,
HasNotAttribute,
HasFamilyAttribute,
HasTag,
HasSourceCount,
Expand Down
Loading
Loading