new reference count filters

svn: r8892
This commit is contained in:
Stéphane Charette
2007-08-30 08:04:28 +00:00
parent 90e3ff34cb
commit 40e940d84a
26 changed files with 477 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ pkgdata_PYTHON = \
_HasMarkerOf.py\
_HasType.py\
_HasNoteMatchingSubstringOf.py\
_HasReferenceCountOf.py\
_MatchesPersonFilter.py\
__init__.py

View File

@@ -0,0 +1,45 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007 Stephane Charette
#
# 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
#
#-------------------------------------------------------------------------
from Filters.Rules._HasReferenceCountBase import HasReferenceCountBase
#-------------------------------------------------------------------------
# "Events with a certain reference count"
#-------------------------------------------------------------------------
class HasReferenceCountOf(HasReferenceCountBase):
"""Events with a reference count of <count>"""
name = _('Events with a reference count of <count>')
description = _("Matches events with a certain reference count")

View File

@@ -36,6 +36,7 @@ from _HasIdOf import HasIdOf
from _RegExpIdOf import RegExpIdOf
from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasReferenceCountOf import HasReferenceCountOf
from _EventPrivate import EventPrivate
from _MatchesFilter import MatchesFilter
from _MatchesPersonFilter import MatchesPersonFilter
@@ -49,6 +50,7 @@ editor_rule_list = [
RegExpIdOf,
HasNoteRegexp,
HasNoteMatchingSubstringOf,
HasReferenceCountOf,
EventPrivate,
MatchesFilter,
MatchesPersonFilter,

View File

@@ -10,6 +10,7 @@ pkgdata_PYTHON = \
_HasIdOf.py\
_HasNoteMatchingSubstringOf.py\
_HasNoteRegexp.py\
_HasReferenceCountOf.py\
_HasRelType.py\
__init__.py\
_RegExpIdOf.py\

View File

@@ -0,0 +1,45 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007 Stephane Charette
#
# 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
#
#-------------------------------------------------------------------------
from Filters.Rules._HasReferenceCountBase import HasReferenceCountBase
#-------------------------------------------------------------------------
# "Family objects with a certain reference count"
#-------------------------------------------------------------------------
class HasReferenceCountOf(HasReferenceCountBase):
"""Family objects with a reference count of <count>"""
name = _('Family objects with a reference count of <count>')
description = _("Matches family objects with a certain reference count")

View File

@@ -39,6 +39,7 @@ from _HasIdOf import HasIdOf
from _RegExpIdOf import RegExpIdOf
from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasReferenceCountOf import HasReferenceCountOf
from _FamilyPrivate import FamilyPrivate
from _HasAttribute import HasAttribute
from _HasEvent import HasEvent
@@ -58,6 +59,7 @@ editor_rule_list = [
RegExpIdOf,
HasNoteRegexp,
HasNoteMatchingSubstringOf,
HasReferenceCountOf,
FamilyPrivate,
HasEvent,
HasAttribute,

View File

@@ -11,6 +11,7 @@ pkgdata_PYTHON = \
_HasGrampsId.py\
_HasNoteRegexBase.py\
_HasNoteSubstrBase.py\
_HasReferenceCountBase.py \
_HasTextMatchingRegexpOf.py\
_HasTextMatchingSubstringOf.py\
__init__.py\

View File

@@ -8,6 +8,7 @@ pkgdata_PYTHON = \
_HasMedia.py\
_HasNoteMatchingSubstringOf.py\
_HasNoteRegexp.py\
_HasReferenceCountOf.py\
_MatchesFilter.py\
_MediaPrivate.py\
_RegExpIdOf.py\

View File

@@ -0,0 +1,45 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007 Stephane Charette
#
# 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
#
#-------------------------------------------------------------------------
from Filters.Rules._HasReferenceCountBase import HasReferenceCountBase
#-------------------------------------------------------------------------
# "Media objects with a certain reference count"
#-------------------------------------------------------------------------
class HasReferenceCountOf(HasReferenceCountBase):
"""Media objects with a reference count of <count>"""
name = _('Media objects with a reference count of <count>')
description = _("Matches media objects with a certain reference count")

View File

@@ -31,6 +31,7 @@ from _HasIdOf import HasIdOf
from _RegExpIdOf import RegExpIdOf
from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasReferenceCountOf import HasReferenceCountOf
from _MediaPrivate import MediaPrivate
from _MatchesFilter import MatchesFilter
from _HasMedia import HasMedia
@@ -41,6 +42,7 @@ editor_rule_list = [
RegExpIdOf,
HasNoteRegexp,
HasNoteMatchingSubstringOf,
HasReferenceCountOf,
MediaPrivate,
MatchesFilter,
]

View File

@@ -9,6 +9,7 @@ pkgdata_PYTHON = \
_HasNoteMatchingSubstringOf.py\
_HasNoteRegexp.py\
_HasNote.py\
_HasReferenceCountOf.py\
_MatchesFilter.py\
_RegExpIdOf.py\
_NotePrivate.py\

View File

@@ -0,0 +1,45 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007 Stephane Charette
#
# 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
#
#-------------------------------------------------------------------------
from Filters.Rules._HasReferenceCountBase import HasReferenceCountBase
#-------------------------------------------------------------------------
# "Notes with a certain reference count"
#-------------------------------------------------------------------------
class HasReferenceCountOf(HasReferenceCountBase):
"""Notes with a reference count of <count>"""
name = _('Notes with a reference count of <count>')
description = _("Matches notes with a certain reference count")

View File

@@ -33,6 +33,7 @@ from _HasMarkerOf import HasMarkerOf
from _RegExpIdOf import RegExpIdOf
from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasReferenceCountOf import HasReferenceCountOf
from _NotePrivate import NotePrivate
from _MatchesFilter import MatchesFilter
from _HasNote import HasNote
@@ -45,6 +46,7 @@ editor_rule_list = [
HasNote,
HasNoteRegexp,
HasNoteMatchingSubstringOf,
HasReferenceCountOf,
NotePrivate,
MatchesFilter,
]

View File

@@ -10,6 +10,7 @@ pkgdata_PYTHON = \
_HasNoteMatchingSubstringOf.py\
_HasNoteRegexp.py\
_HasPlace.py\
_HasReferenceCountOf.py\
_MatchesFilter.py\
_MatchesEventFilter.py\
_PlacePrivate.py\

View File

@@ -0,0 +1,45 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007 Stephane Charette
#
# 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
#
#-------------------------------------------------------------------------
from Filters.Rules._HasReferenceCountBase import HasReferenceCountBase
#-------------------------------------------------------------------------
# "Place objects with a certain reference count"
#-------------------------------------------------------------------------
class HasReferenceCountOf(HasReferenceCountBase):
"""Place objects with a reference count of <count>"""
name = _('Place objects with a reference count of <count>')
description = _("Matches place objects with a certain reference count")

View File

@@ -31,6 +31,7 @@ from _HasIdOf import HasIdOf
from _RegExpIdOf import RegExpIdOf
from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasReferenceCountOf import HasReferenceCountOf
from _PlacePrivate import PlacePrivate
from _MatchesFilter import MatchesFilter
from _HasPlace import HasPlace
@@ -44,6 +45,7 @@ editor_rule_list = [
RegExpIdOf,
HasNoteRegexp,
HasNoteMatchingSubstringOf,
HasReferenceCountOf,
PlacePrivate,
MatchesFilter,
HasPlace,

View File

@@ -7,6 +7,7 @@ pkgdata_PYTHON = \
_HasIdOf.py\
_HasNoteMatchingSubstringOf.py\
_HasNoteRegexp.py\
_HasReferenceCountOf.py\
_HasRepo.py\
_MatchesFilter.py\
_RegExpIdOf.py\

View File

@@ -0,0 +1,45 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007 Stephane Charette
#
# 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
#
#-------------------------------------------------------------------------
from Filters.Rules._HasReferenceCountBase import HasReferenceCountBase
#-------------------------------------------------------------------------
# "Repositories with a certain reference count"
#-------------------------------------------------------------------------
class HasReferenceCountOf(HasReferenceCountBase):
"""Repositories with a reference count of <count>"""
name = _('Repositories with a reference count of <count>')
description = _("Matches repositories with a certain reference count")

View File

@@ -31,6 +31,7 @@ from _HasIdOf import HasIdOf
from _RegExpIdOf import RegExpIdOf
from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasReferenceCountOf import HasReferenceCountOf
from _RepoPrivate import RepoPrivate
from _MatchesFilter import MatchesFilter
from _HasRepo import HasRepo
@@ -41,6 +42,7 @@ editor_rule_list = [
RegExpIdOf,
HasNoteRegexp,
HasNoteMatchingSubstringOf,
HasReferenceCountOf,
RepoPrivate,
MatchesFilter,
]

View File

@@ -7,6 +7,7 @@ pkgdata_PYTHON = \
_SourcePrivate.py\
_RegExpIdOf.py\
_HasNoteMatchingSubstringOf.py\
_HasReferenceCountOf.py\
_AllSources.py\
_HasIdOf.py\
_HasSource.py\

View File

@@ -0,0 +1,45 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007 Stephane Charette
#
# 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
#
#-------------------------------------------------------------------------
from Filters.Rules._HasReferenceCountBase import HasReferenceCountBase
#-------------------------------------------------------------------------
# "Source objects with a certain reference count"
#-------------------------------------------------------------------------
class HasReferenceCountOf(HasReferenceCountBase):
"""Source objects with a reference count of <count>"""
name = _('Source objects with a reference count of <count>')
description = _("Matches source objects with a certain reference count")

View File

@@ -31,6 +31,7 @@ from _HasIdOf import HasIdOf
from _RegExpIdOf import RegExpIdOf
from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasReferenceCountOf import HasReferenceCountOf
from _SourcePrivate import SourcePrivate
from _MatchesFilter import MatchesFilter
from _HasSource import HasSource
@@ -41,6 +42,7 @@ editor_rule_list = [
RegExpIdOf,
HasNoteRegexp,
HasNoteMatchingSubstringOf,
HasReferenceCountOf,
SourcePrivate,
MatchesFilter,
]

View File

@@ -0,0 +1,61 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007 Stephane Charette
#
# 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
#
#-------------------------------------------------------------------------
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "Objects with a certain reference count"
#-------------------------------------------------------------------------
class HasReferenceCountBase(Rule):
"""Objects with a reference count of <count>"""
labels = [ _('Reference count must be:'), _('Reference count:')]
name = _('Objects with a reference count of <count>')
description = _("Matches objects with a certain reference count")
category = _('General filters')
def apply(self,db,object):
handle = object.get_handle()
count = 0
for item in db.find_backlink_handles(handle):
count += 1
value = int(self.list[1])
if self.list[0] == _('lesser than'):
return count < value
elif self.list[0] == _('greater than'):
return count > value
return count == value