From 40e940d84a93c2f21dc6f4d6e1df18123c7c6739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Charette?= Date: Thu, 30 Aug 2007 08:04:28 +0000 Subject: [PATCH] new reference count filters svn: r8892 --- ChangeLog | 35 +++++++++++ po/POTFILES.in | 8 +++ src/FilterEditor/_EditRule.py | 36 +++++++++++ src/Filters/Rules/Event/Makefile.am | 1 + .../Rules/Event/_HasReferenceCountOf.py | 45 ++++++++++++++ src/Filters/Rules/Event/__init__.py | 2 + src/Filters/Rules/Family/Makefile.am | 1 + .../Rules/Family/_HasReferenceCountOf.py | 45 ++++++++++++++ src/Filters/Rules/Family/__init__.py | 2 + src/Filters/Rules/Makefile.am | 1 + src/Filters/Rules/MediaObject/Makefile.am | 1 + .../Rules/MediaObject/_HasReferenceCountOf.py | 45 ++++++++++++++ src/Filters/Rules/MediaObject/__init__.py | 2 + src/Filters/Rules/Note/Makefile.am | 1 + .../Rules/Note/_HasReferenceCountOf.py | 45 ++++++++++++++ src/Filters/Rules/Note/__init__.py | 2 + src/Filters/Rules/Place/Makefile.am | 1 + .../Rules/Place/_HasReferenceCountOf.py | 45 ++++++++++++++ src/Filters/Rules/Place/__init__.py | 2 + src/Filters/Rules/Repository/Makefile.am | 1 + .../Rules/Repository/_HasReferenceCountOf.py | 45 ++++++++++++++ src/Filters/Rules/Repository/__init__.py | 2 + src/Filters/Rules/Source/Makefile.am | 1 + .../Rules/Source/_HasReferenceCountOf.py | 45 ++++++++++++++ src/Filters/Rules/Source/__init__.py | 2 + src/Filters/Rules/_HasReferenceCountBase.py | 61 +++++++++++++++++++ 26 files changed, 477 insertions(+) create mode 100644 src/Filters/Rules/Event/_HasReferenceCountOf.py create mode 100644 src/Filters/Rules/Family/_HasReferenceCountOf.py create mode 100644 src/Filters/Rules/MediaObject/_HasReferenceCountOf.py create mode 100644 src/Filters/Rules/Note/_HasReferenceCountOf.py create mode 100644 src/Filters/Rules/Place/_HasReferenceCountOf.py create mode 100644 src/Filters/Rules/Repository/_HasReferenceCountOf.py create mode 100644 src/Filters/Rules/Source/_HasReferenceCountOf.py create mode 100644 src/Filters/Rules/_HasReferenceCountBase.py diff --git a/ChangeLog b/ChangeLog index ebeebaee1..bfeb125ef 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,38 @@ +2007-08-30 Stephane Charette + * src/FilterEditor/_EditRule.py: new reference count filters + * src/Filters/Rules/Repository/__init__.py: new reference count filters + * src/Filters/Rules/Repository/Makefile.am: new reference count filters + * src/Filters/Rules/Repository/_HasReferenceCountOf.py: new reference + count filters + * src/Filters/Rules/Event/__init__.py: new reference count filters + * src/Filters/Rules/Event/Makefile.am: new reference count filters + * src/Filters/Rules/Event/_HasReferenceCountOf.py: new reference count + filters + * src/Filters/Rules/Family/__init__.py: new reference count filters + * src/Filters/Rules/Family/Makefile.am: new reference count filters + * src/Filters/Rules/Family/_HasReferenceCountOf.py: new reference count + filters + * src/Filters/Rules/Place/__init__.py: new reference count filters + * src/Filters/Rules/Place/Makefile.am: new reference count filters + * src/Filters/Rules/Place/_HasReferenceCountOf.py: new reference count + filters + * src/Filters/Rules/Makefile.am: new reference count filters + * src/Filters/Rules/_HasReferenceCountBase.py: new reference count + filters + * src/Filters/Rules/Source/__init__.py: new reference count filters + * src/Filters/Rules/Source/Makefile.am: new reference count filters + * src/Filters/Rules/Source/_HasReferenceCountOf.py: new reference count + filters + * src/Filters/Rules/Note/__init__.py: new reference count filters + * src/Filters/Rules/Note/Makefile.am: new reference count filters + * src/Filters/Rules/Note/_HasReferenceCountOf.py: new reference count + filters + * src/Filters/Rules/MediaObject/__init__.py: new reference count filters + * src/Filters/Rules/MediaObject/Makefile.am: new reference count filters + * src/Filters/Rules/MediaObject/_HasReferenceCountOf.py: new reference + count filters + * po/POTFILES.in: new reference count filters + 2007-08-29 Don Allingham * src/RelLib/_Source.py: fix fast unserialize() * src/RelLib/_Place.py: fix fast unserialize() diff --git a/po/POTFILES.in b/po/POTFILES.in index 4335a1ebc..789eec98d 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -459,6 +459,7 @@ src/Filters/Rules/_HasEventBase.py src/Filters/Rules/_HasGrampsId.py src/Filters/Rules/_HasNoteRegexBase.py src/Filters/Rules/_HasNoteSubstrBase.py +src/Filters/Rules/_HasReferenceCountBase.py src/Filters/Rules/_HasTextMatchingRegexpOf.py src/Filters/Rules/_HasTextMatchingSubstringOf.py src/Filters/Rules/__init__.py @@ -542,6 +543,7 @@ src/Filters/Rules/Family/_HasEvent.py src/Filters/Rules/Family/_HasIdOf.py src/Filters/Rules/Family/_HasNoteMatchingSubstringOf.py src/Filters/Rules/Family/_HasNoteRegexp.py +src/Filters/Rules/Family/_HasReferenceCountOf.py src/Filters/Rules/Family/_HasRelType.py src/Filters/Rules/Family/_RegExpIdOf.py src/Filters/Rules/Family/_MatchesFilter.py @@ -564,6 +566,7 @@ src/Filters/Rules/Family/_HasMarkerOf.py src/Filters/Rules/Event/_MatchesFilter.py src/Filters/Rules/Event/_EventPrivate.py src/Filters/Rules/Event/_HasNoteRegexp.py +src/Filters/Rules/Event/_HasReferenceCountOf.py src/Filters/Rules/Event/_RegExpIdOf.py src/Filters/Rules/Event/_AllEvents.py src/Filters/Rules/Event/_HasIdOf.py @@ -580,6 +583,7 @@ src/Filters/Rules/Place/_HasNoLatOrLon.py src/Filters/Rules/Place/_HasNoteMatchingSubstringOf.py src/Filters/Rules/Place/_HasNoteRegexp.py src/Filters/Rules/Place/_HasPlace.py +src/Filters/Rules/Place/_HasReferenceCountOf.py src/Filters/Rules/Place/_InLatLonNeighborhood.py src/Filters/Rules/Place/_MatchesFilter.py src/Filters/Rules/Place/_MatchesEventFilter.py @@ -591,6 +595,7 @@ src/Filters/Rules/Place/__init__.py src/Filters/Rules/Source/_MatchesFilter.py src/Filters/Rules/Source/_SourcePrivate.py src/Filters/Rules/Source/_RegExpIdOf.py +src/Filters/Rules/Source/_HasReferenceCountOf.py src/Filters/Rules/Source/_HasSource.py src/Filters/Rules/Source/_HasNoteMatchingSubstringOf.py src/Filters/Rules/Source/_AllSources.py @@ -604,6 +609,7 @@ src/Filters/Rules/MediaObject/_HasIdOf.py src/Filters/Rules/MediaObject/_HasMedia.py src/Filters/Rules/MediaObject/_HasNoteMatchingSubstringOf.py src/Filters/Rules/MediaObject/_HasNoteRegexp.py +src/Filters/Rules/MediaObject/_HasReferenceCountOf.py src/Filters/Rules/MediaObject/_MatchesFilter.py src/Filters/Rules/MediaObject/_MediaPrivate.py src/Filters/Rules/MediaObject/_RegExpIdOf.py @@ -614,6 +620,7 @@ src/Filters/Rules/Repository/_AllRepos.py src/Filters/Rules/Repository/_HasIdOf.py src/Filters/Rules/Repository/_HasNoteMatchingSubstringOf.py src/Filters/Rules/Repository/_HasNoteRegexp.py +src/Filters/Rules/Repository/_HasReferenceCountOf.py src/Filters/Rules/Repository/_HasRepo.py src/Filters/Rules/Repository/_MatchesFilter.py src/Filters/Rules/Repository/_RegExpIdOf.py @@ -627,6 +634,7 @@ src/Filters/Rules/Note/_HasMarkerOf.py src/Filters/Rules/Note/_HasNoteMatchingSubstringOf.py src/Filters/Rules/Note/_HasNoteRegexp.py src/Filters/Rules/Note/_HasNote.py +src/Filters/Rules/Note/_HasReferenceCountOf.py src/Filters/Rules/Note/_MatchesFilter.py src/Filters/Rules/Note/_RegExpIdOf.py src/Filters/Rules/Note/_NotePrivate.py diff --git a/src/FilterEditor/_EditRule.py b/src/FilterEditor/_EditRule.py index f7094cf2b..4da007651 100644 --- a/src/FilterEditor/_EditRule.py +++ b/src/FilterEditor/_EditRule.py @@ -166,6 +166,38 @@ class MyFilters(gtk.ComboBox): if val in self.flist: self.set_active(self.flist.index(val)) +#------------------------------------------------------------------------- +# +# MyLesserEqualGreater - Combo box to allow selection of "<", "=", or ">" +# +#------------------------------------------------------------------------- +class MyLesserEqualGreater(gtk.ComboBox): + + def __init__(self): + gtk.ComboBox.__init__(self) + store = gtk.ListStore(str) + self.set_model(store) + cell = gtk.CellRendererText() + self.pack_start(cell,True) + self.add_attribute(cell,'text',0) + self.clist = [_('lesser than'), _('equal to'), _('greater than')] + for name in self.clist: + store.append(row=[name]) + self.set_active(0) + self.show() + + def get_text(self): + active = self.get_active() + if active < 0: + return _('equal to') + return self.clist[active] + + def set_text(self,val): + if val in self.clist: + self.set_active(self.clist.index(val)) + else: + self.set_active(self.clist.index(_('equal to'))) + #------------------------------------------------------------------------- # # MySource - Combo box with list of sources with a standard interface @@ -424,6 +456,10 @@ class EditRule(ManagedWindow.ManagedWindow): l.show() if v == _('Place:'): t = MyPlaces([]) + elif v == _('Reference count:'): + t = MyInteger(0, 999) + elif v == _('Reference count must be:'): + t = MyLesserEqualGreater() elif v == _('Number of generations:'): t = MyInteger(1,32) elif v == _('ID:'): diff --git a/src/Filters/Rules/Event/Makefile.am b/src/Filters/Rules/Event/Makefile.am index 51e3eec92..2916385cc 100644 --- a/src/Filters/Rules/Event/Makefile.am +++ b/src/Filters/Rules/Event/Makefile.am @@ -12,6 +12,7 @@ pkgdata_PYTHON = \ _HasMarkerOf.py\ _HasType.py\ _HasNoteMatchingSubstringOf.py\ + _HasReferenceCountOf.py\ _MatchesPersonFilter.py\ __init__.py diff --git a/src/Filters/Rules/Event/_HasReferenceCountOf.py b/src/Filters/Rules/Event/_HasReferenceCountOf.py new file mode 100644 index 000000000..17754fe6a --- /dev/null +++ b/src/Filters/Rules/Event/_HasReferenceCountOf.py @@ -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 """ + + name = _('Events with a reference count of ') + description = _("Matches events with a certain reference count") + diff --git a/src/Filters/Rules/Event/__init__.py b/src/Filters/Rules/Event/__init__.py index 912015c89..4b5b75154 100644 --- a/src/Filters/Rules/Event/__init__.py +++ b/src/Filters/Rules/Event/__init__.py @@ -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, diff --git a/src/Filters/Rules/Family/Makefile.am b/src/Filters/Rules/Family/Makefile.am index a005d30a1..e3093c80e 100644 --- a/src/Filters/Rules/Family/Makefile.am +++ b/src/Filters/Rules/Family/Makefile.am @@ -10,6 +10,7 @@ pkgdata_PYTHON = \ _HasIdOf.py\ _HasNoteMatchingSubstringOf.py\ _HasNoteRegexp.py\ + _HasReferenceCountOf.py\ _HasRelType.py\ __init__.py\ _RegExpIdOf.py\ diff --git a/src/Filters/Rules/Family/_HasReferenceCountOf.py b/src/Filters/Rules/Family/_HasReferenceCountOf.py new file mode 100644 index 000000000..23d40066f --- /dev/null +++ b/src/Filters/Rules/Family/_HasReferenceCountOf.py @@ -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 """ + + name = _('Family objects with a reference count of ') + description = _("Matches family objects with a certain reference count") + diff --git a/src/Filters/Rules/Family/__init__.py b/src/Filters/Rules/Family/__init__.py index cc2cec33a..82b1bffb3 100644 --- a/src/Filters/Rules/Family/__init__.py +++ b/src/Filters/Rules/Family/__init__.py @@ -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, diff --git a/src/Filters/Rules/Makefile.am b/src/Filters/Rules/Makefile.am index ca5d5a484..1816d2db7 100644 --- a/src/Filters/Rules/Makefile.am +++ b/src/Filters/Rules/Makefile.am @@ -11,6 +11,7 @@ pkgdata_PYTHON = \ _HasGrampsId.py\ _HasNoteRegexBase.py\ _HasNoteSubstrBase.py\ + _HasReferenceCountBase.py \ _HasTextMatchingRegexpOf.py\ _HasTextMatchingSubstringOf.py\ __init__.py\ diff --git a/src/Filters/Rules/MediaObject/Makefile.am b/src/Filters/Rules/MediaObject/Makefile.am index c7399f9e1..9dfdd49b0 100644 --- a/src/Filters/Rules/MediaObject/Makefile.am +++ b/src/Filters/Rules/MediaObject/Makefile.am @@ -8,6 +8,7 @@ pkgdata_PYTHON = \ _HasMedia.py\ _HasNoteMatchingSubstringOf.py\ _HasNoteRegexp.py\ + _HasReferenceCountOf.py\ _MatchesFilter.py\ _MediaPrivate.py\ _RegExpIdOf.py\ diff --git a/src/Filters/Rules/MediaObject/_HasReferenceCountOf.py b/src/Filters/Rules/MediaObject/_HasReferenceCountOf.py new file mode 100644 index 000000000..5a9d50dda --- /dev/null +++ b/src/Filters/Rules/MediaObject/_HasReferenceCountOf.py @@ -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 """ + + name = _('Media objects with a reference count of ') + description = _("Matches media objects with a certain reference count") + diff --git a/src/Filters/Rules/MediaObject/__init__.py b/src/Filters/Rules/MediaObject/__init__.py index c1ac1d73c..5558c57ba 100644 --- a/src/Filters/Rules/MediaObject/__init__.py +++ b/src/Filters/Rules/MediaObject/__init__.py @@ -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, ] diff --git a/src/Filters/Rules/Note/Makefile.am b/src/Filters/Rules/Note/Makefile.am index e0ab5bf26..2e92cad59 100644 --- a/src/Filters/Rules/Note/Makefile.am +++ b/src/Filters/Rules/Note/Makefile.am @@ -9,6 +9,7 @@ pkgdata_PYTHON = \ _HasNoteMatchingSubstringOf.py\ _HasNoteRegexp.py\ _HasNote.py\ + _HasReferenceCountOf.py\ _MatchesFilter.py\ _RegExpIdOf.py\ _NotePrivate.py\ diff --git a/src/Filters/Rules/Note/_HasReferenceCountOf.py b/src/Filters/Rules/Note/_HasReferenceCountOf.py new file mode 100644 index 000000000..95990af97 --- /dev/null +++ b/src/Filters/Rules/Note/_HasReferenceCountOf.py @@ -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 """ + + name = _('Notes with a reference count of ') + description = _("Matches notes with a certain reference count") + diff --git a/src/Filters/Rules/Note/__init__.py b/src/Filters/Rules/Note/__init__.py index 6fb5807e4..ba0627e90 100644 --- a/src/Filters/Rules/Note/__init__.py +++ b/src/Filters/Rules/Note/__init__.py @@ -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, ] diff --git a/src/Filters/Rules/Place/Makefile.am b/src/Filters/Rules/Place/Makefile.am index cb6f0689a..b2e867252 100644 --- a/src/Filters/Rules/Place/Makefile.am +++ b/src/Filters/Rules/Place/Makefile.am @@ -10,6 +10,7 @@ pkgdata_PYTHON = \ _HasNoteMatchingSubstringOf.py\ _HasNoteRegexp.py\ _HasPlace.py\ + _HasReferenceCountOf.py\ _MatchesFilter.py\ _MatchesEventFilter.py\ _PlacePrivate.py\ diff --git a/src/Filters/Rules/Place/_HasReferenceCountOf.py b/src/Filters/Rules/Place/_HasReferenceCountOf.py new file mode 100644 index 000000000..9ffa3f38e --- /dev/null +++ b/src/Filters/Rules/Place/_HasReferenceCountOf.py @@ -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 """ + + name = _('Place objects with a reference count of ') + description = _("Matches place objects with a certain reference count") + diff --git a/src/Filters/Rules/Place/__init__.py b/src/Filters/Rules/Place/__init__.py index 1e3965823..63b7f31f9 100644 --- a/src/Filters/Rules/Place/__init__.py +++ b/src/Filters/Rules/Place/__init__.py @@ -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, diff --git a/src/Filters/Rules/Repository/Makefile.am b/src/Filters/Rules/Repository/Makefile.am index 98a6b207c..7d3927c00 100644 --- a/src/Filters/Rules/Repository/Makefile.am +++ b/src/Filters/Rules/Repository/Makefile.am @@ -7,6 +7,7 @@ pkgdata_PYTHON = \ _HasIdOf.py\ _HasNoteMatchingSubstringOf.py\ _HasNoteRegexp.py\ + _HasReferenceCountOf.py\ _HasRepo.py\ _MatchesFilter.py\ _RegExpIdOf.py\ diff --git a/src/Filters/Rules/Repository/_HasReferenceCountOf.py b/src/Filters/Rules/Repository/_HasReferenceCountOf.py new file mode 100644 index 000000000..b1b3834d7 --- /dev/null +++ b/src/Filters/Rules/Repository/_HasReferenceCountOf.py @@ -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 """ + + name = _('Repositories with a reference count of ') + description = _("Matches repositories with a certain reference count") + diff --git a/src/Filters/Rules/Repository/__init__.py b/src/Filters/Rules/Repository/__init__.py index ebae3c982..16922cbee 100644 --- a/src/Filters/Rules/Repository/__init__.py +++ b/src/Filters/Rules/Repository/__init__.py @@ -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, ] diff --git a/src/Filters/Rules/Source/Makefile.am b/src/Filters/Rules/Source/Makefile.am index c54d08742..4231cd088 100644 --- a/src/Filters/Rules/Source/Makefile.am +++ b/src/Filters/Rules/Source/Makefile.am @@ -7,6 +7,7 @@ pkgdata_PYTHON = \ _SourcePrivate.py\ _RegExpIdOf.py\ _HasNoteMatchingSubstringOf.py\ + _HasReferenceCountOf.py\ _AllSources.py\ _HasIdOf.py\ _HasSource.py\ diff --git a/src/Filters/Rules/Source/_HasReferenceCountOf.py b/src/Filters/Rules/Source/_HasReferenceCountOf.py new file mode 100644 index 000000000..2c236d56b --- /dev/null +++ b/src/Filters/Rules/Source/_HasReferenceCountOf.py @@ -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 """ + + name = _('Source objects with a reference count of ') + description = _("Matches source objects with a certain reference count") + diff --git a/src/Filters/Rules/Source/__init__.py b/src/Filters/Rules/Source/__init__.py index d10a3df52..c0f3c9694 100644 --- a/src/Filters/Rules/Source/__init__.py +++ b/src/Filters/Rules/Source/__init__.py @@ -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, ] diff --git a/src/Filters/Rules/_HasReferenceCountBase.py b/src/Filters/Rules/_HasReferenceCountBase.py new file mode 100644 index 000000000..ab9f1fe8e --- /dev/null +++ b/src/Filters/Rules/_HasReferenceCountBase.py @@ -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 """ + + labels = [ _('Reference count must be:'), _('Reference count:')] + name = _('Objects with a reference count of ') + 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 +