GEPS023: merge branch (changes 17960-18546) into trunk

svn: r18548
This commit is contained in:
Tim G L Lyons
2011-12-04 17:09:17 +00:00
211 changed files with 9529 additions and 2316 deletions

View File

@@ -0,0 +1,33 @@
# This is the src/Filters/Rules/Citation level Makefile for Gramps
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Citation
pkgdata_PYTHON = \
__init__.py \
_AllCitations.py \
_ChangedSince.py \
_CitationPrivate.py \
_HasGallery.py \
_HasIdOf.py \
_HasNote.py \
_HasNoteMatchingSubstringOf.py \
_HasNoteRegexp.py \
_HasReferenceCountOf.py \
_HasSource.py \
_MatchesFilter.py \
_MatchesPageSubstringOf.py \
_MatchesRepositoryFilter.py \
_MatchesSourceFilter.py \
_RegExpIdOf.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Citation
pkgpythondir = @pkgpythondir@/Filters/Rules/Citation
# Clean up all the byte-compiled files
MOSTLYCLEANFILES = *pyc *pyo
GRAMPS_PY_MODPATH = "../../../"
pycheck:
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
pychecker $(pkgdata_PYTHON));

View File

@@ -0,0 +1,47 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._Everything import Everything
#-------------------------------------------------------------------------
#
# Everyone
#
#-------------------------------------------------------------------------
class AllCitations(Everything):
"""Matches every citation"""
name = _('Every citation')
description = _('Matches every citation in the database')

View File

@@ -0,0 +1,50 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
#-------------------------------------------------------------------------
#
# ChangedSince
#
#-------------------------------------------------------------------------
class ChangedSince(ChangedSinceBase):
"""Rule that checks for citations changed since a specific time."""
labels = [ _('Changed after:'), _('but before:') ]
name = _('Citations changed after <date time>')
description = _("Matches citation records changed after a specified "
"date-time (yyyy-mm-dd hh:mm:ss) or in the range, if a second "
"date-time is given.")

View File

@@ -0,0 +1,45 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._IsPrivate import IsPrivate
#-------------------------------------------------------------------------
# "Family marked private"
#-------------------------------------------------------------------------
class CitationPrivate(IsPrivate):
"""Citation marked private"""
name = _('Citations marked private')
description = _("Matches citations that are indicated as private")

View File

@@ -0,0 +1,47 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2008 Brian G. Matherly
# Copyright (C) 2008 Jerome Rapinat
# Copyright (C) 2008 Benny Malengier
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasGalleryBase import HasGalleryBase
#-------------------------------------------------------------------------
# "Sources who have media object reference"
#-------------------------------------------------------------------------
class HasGallery(HasGalleryBase):
"""Rule that checks for citation who has media object reference"""
name = _('Citations with <count> media')
description = _("Matches citations with a certain number of items in the gallery")

View File

@@ -0,0 +1,47 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import HasGrampsId
#-------------------------------------------------------------------------
#
# HasIdOf
#
#-------------------------------------------------------------------------
class HasIdOf(HasGrampsId):
"""Rule that checks for a citation with a specific GRAMPS ID"""
name = _('Citation with <Id>')
description = _("Matches a citation with a specified Gramps ID")

View File

@@ -0,0 +1,48 @@
#
# 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
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasNoteBase import HasNoteBase
#-------------------------------------------------------------------------
# "Sources having notes"
#-------------------------------------------------------------------------
class HasNote(HasNoteBase):
"""Citations having notes"""
name = _('Citations having <count> notes')
description = _("Matches citations having a certain number of notes")

View File

@@ -0,0 +1,47 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasNoteSubstrBase import HasNoteSubstrBase
#-------------------------------------------------------------------------
# "Events having notes that contain a substring"
#-------------------------------------------------------------------------
class HasNoteMatchingSubstringOf(HasNoteSubstrBase):
"""Citations having notes containing <substring>"""
name = _('Citations having notes containing <substring>')
description = _("Matches citations whose notes contain text "
"matching a substring")

View File

@@ -0,0 +1,45 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasNoteRegexBase import HasNoteRegexBase
#-------------------------------------------------------------------------
# "Sources having notes that contain a substring"
#-------------------------------------------------------------------------
class HasNoteRegexp(HasNoteRegexBase):
name = _('Citations having notes containing <regular expression>')
description = _("Matches citations whose notes contain text "
"matching a regular expression")

View File

@@ -0,0 +1,46 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2007 Stephane Charette
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasReferenceCountBase import HasReferenceCountBase
#-------------------------------------------------------------------------
# "Source objects with a certain reference count"
#-------------------------------------------------------------------------
class HasReferenceCountOf(HasReferenceCountBase):
"""Citation objects with a reference count of <count>"""
name = _('Citations with a reference count of <count>')
description = _("Matches citations with a certain reference count")

View File

@@ -2,6 +2,7 @@
# 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
@@ -20,6 +21,9 @@
# $Id$
"""
Filter rule to match citation with a particular source.
"""
#-------------------------------------------------------------------------
#
# Standard Python modules
@@ -32,32 +36,27 @@ from gen.ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._Rule import Rule
from Filters.Rules._HasSourceBase import HasSourceBase
#-------------------------------------------------------------------------
#
# HasSource
# HasEvent
#
#-------------------------------------------------------------------------
class HasSource(Rule):
"""Rule that checks for a person with a particular value"""
class HasSource(HasSourceBase):
"""Rule that checks for an citation with a particular value"""
labels = [ _('Title:'),
_('Author:'),
_('Publication:') ]
name = _('Sources matching parameters')
description = _("Matches sources with particular parameters")
category = _('General filters')
def apply(self,db,source):
if not self.match_substring(0,source.get_title()):
return False
if not self.match_substring(1,source.get_author()):
return False
if not self.match_substring(2,source.get_publication_info()):
return False
return True
description = _("Matches citations with a source of a particular "
"value")
category = _('Source filters')
def apply(self, dbase, citation):
source = dbase.get_source_from_handle(
citation.get_reference_handle())
if HasSourceBase.apply(self, dbase, source):
return True
return False

View File

@@ -0,0 +1,48 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
#-------------------------------------------------------------------------
#
# MatchesFilter
#
#-------------------------------------------------------------------------
class MatchesFilter(MatchesFilterBase):
"""Rule that checks against another filter"""
name = _('Citations matching the <filter>')
description = _("Matches citations matched by the specified filter name")
namespace = 'Citation'

View File

@@ -0,0 +1,54 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2011 Helge Herz
#
# 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 gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import Rule
#-------------------------------------------------------------------------
# "Sources having a title that contain a substring"
#-------------------------------------------------------------------------
class MatchesPageSubstringOf(Rule):
"""Citation Volume/Page title containing <substring>"""
labels = [ _('Substring:')]
name = _('Citation Volume/Page containing <substring>')
description = _("Matches citations whose Volume/Page contains a "
"certain substring")
category = _('General filters')
def apply(self, db, object):
""" Apply the filter """
title = object.get_page()
if title.upper().find(self.list[0].upper()) != -1:
return True
return False

View File

@@ -0,0 +1,72 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2011 Benny Malengier
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
import logging
LOG = logging.getLogger(".citation")
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
# "Sources which reference a repository by selection"
#-------------------------------------------------------------------------
class MatchesRepositoryFilter(MatchesFilterBase):
"""Citations which have a source which references the selected repository"""
labels = [ _('Repository filter name:') ]
name = _('Citations with a source with a repository reference '
'matching the <repository filter>')
description = _("Matches citations with sources with a repository "
"reference that match a certain repository filter")
category = _('General filters')
# we want to have this filter show repository filters
namespace = 'Repository'
def prepare(self, db):
MatchesFilterBase.prepare(self, db)
self.MRF_filt = self.find_filter()
def apply(self, db, object):
if self.MRF_filt is None :
return False
source_handle = object.source_handle
source = db.get_source_from_handle(source_handle)
repolist = [x.ref for x in source.get_reporef_list()]
for repohandle in repolist:
#check if repo in repository filter
if self.MRF_filt.check(db, repohandle):
return True
return False

View File

@@ -0,0 +1,69 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2002-2006 Donald N. Allingham
# Copyright (C) 2010 Benny Malengier
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
#
# MatchesFilter
#
#-------------------------------------------------------------------------
class MatchesSourceFilter(MatchesFilterBase):
"""
Rule that checks against another filter.
"""
labels = [_('Source filter name:')]
name = _('Citations with source matching the <source filter>')
description = _("Matches citations with sources that match the "
"specified source filter name")
category = _('General filters')
# we want to have this filter show source filters
namespace = 'Source'
def prepare(self, db):
MatchesFilterBase.prepare(self, db)
self.MRF_filt = self.find_filter()
def apply(self, db, object):
if self.MRF_filt is None :
return False
source_handle = object.source_handle
if self.MRF_filt.check(db, source_handle):
return True
return False

View File

@@ -0,0 +1,51 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._RegExpIdBase import RegExpIdBase
#-------------------------------------------------------------------------
#
# HasIdOf
#
#-------------------------------------------------------------------------
class RegExpIdOf(RegExpIdBase):
"""
Rule that checks for a citation whose GRAMPS ID
matches regular expression.
"""
name = _('Citations with <Id> matching regular expression')
description = _("Matches citations whose Gramps ID matches "
"the regular expression")

View File

@@ -0,0 +1,63 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2002-2007 Donald N. Allingham
# Copyright (C) 2007-2008 Brian G. Matherly
# 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$
"""
Package providing filter rules for GRAMPS.
"""
from Filters.Rules._HasCitationBase import HasCitationBase as HasCitation
from _AllCitations import AllCitations
from _ChangedSince import ChangedSince
from _CitationPrivate import CitationPrivate
from _HasGallery import HasGallery
from _HasIdOf import HasIdOf
from _HasNote import HasNote
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasNoteRegexp import HasNoteRegexp
from _HasReferenceCountOf import HasReferenceCountOf
from _HasSource import HasSource
from _MatchesFilter import MatchesFilter
from _MatchesPageSubstringOf import MatchesPageSubstringOf
from _MatchesRepositoryFilter import MatchesRepositoryFilter
from _MatchesSourceFilter import MatchesSourceFilter
from _RegExpIdOf import RegExpIdOf
editor_rule_list = [
AllCitations,
ChangedSince,
CitationPrivate,
HasGallery,
HasIdOf,
HasNote,
HasNoteMatchingSubstringOf,
HasNoteRegexp,
HasReferenceCountOf,
HasSource,
MatchesFilter,
MatchesPageSubstringOf,
MatchesRepositoryFilter,
MatchesSourceFilter,
RegExpIdOf
]

View File

@@ -9,11 +9,12 @@ pkgdata_PYTHON = \
_HasNoteRegexp.py\
_RegExpIdOf.py\
_AllEvents.py\
_HasCitation.py \
_HasData.py\
_HasGallery.py \
_HasIdOf.py\
_HasNote.py \
_HasSource.py \
_HasSourceCount.py \
_HasType.py\
_HasNoteMatchingSubstringOf.py\
_HasReferenceCountOf.py\

View File

@@ -0,0 +1,61 @@
#
# 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$
"""
Filter rule to match event with a particular citation.
"""
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasCitationBase import HasCitationBase
#-------------------------------------------------------------------------
#
# HasEvent
#
#-------------------------------------------------------------------------
class HasCitation(HasCitationBase):
"""Rule that checks for an event with a particular value"""
labels = [ _('Volume/Page:'),
_('Date:'),
_('Confidence level:')]
name = _('Event with the <citation>')
description = _("Matches events with a citation of a particular "
"value")
def apply(self, dbase, event):
for citation_handle in event.get_citation_list():
citation = dbase.get_citation_from_handle(citation_handle)
if HasCitationBase.apply(self, dbase, citation):
return True
return False

View File

@@ -19,9 +19,8 @@
# 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/Event/_HasSource.py
# $Id$
#
#-------------------------------------------------------------------------
#
@@ -35,12 +34,12 @@ from gen.ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasSourceBase import HasSourceBase
from Filters.Rules._HasSourceCountBase import HasSourceCountBase
#-------------------------------------------------------------------------
# "People having sources"
#-------------------------------------------------------------------------
class HasSource(HasSourceBase):
class HasSourceCount(HasSourceCountBase):
"""Events with sources"""
name = _('Events with <count> sources')

View File

@@ -3,6 +3,7 @@
#
# Copyright (C) 2002-2006 Donald N. Allingham
# Copyright (C) 2010 Benny Malengier
# 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
@@ -49,7 +50,7 @@ class MatchesSourceFilter(MatchesSourceFilterBase):
name = _('Events with source matching the <source filter>')
description = _("Matches events with sources that match the "
"specified source filter name")
category = _('General filters')
category = _('Citation/source filters')
# we want to have this filter show source filters
namespace = 'Source'

View File

@@ -3,6 +3,7 @@
#
# Copyright (C) 2002-2006 Donald N. Allingham
# Copyright (C) 2007-2008 Brian G. Matherly
# 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
@@ -32,11 +33,12 @@ from _AllEvents import AllEvents
from _HasGallery import HasGallery
from _HasIdOf import HasIdOf
from _RegExpIdOf import RegExpIdOf
from _HasCitation import HasCitation
from _HasNote import HasNote
from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasReferenceCountOf import HasReferenceCountOf
from _HasSource import HasSource
from _HasSourceCount import HasSourceCount
from _EventPrivate import EventPrivate
from _MatchesFilter import MatchesFilter
from _MatchesPersonFilter import MatchesPersonFilter
@@ -52,11 +54,12 @@ editor_rule_list = [
HasIdOf,
HasGallery,
RegExpIdOf,
HasCitation,
HasNote,
HasNoteRegexp,
HasNoteMatchingSubstringOf,
HasReferenceCountOf,
HasSource,
HasSourceCount,
EventPrivate,
MatchesFilter,
MatchesPersonFilter,

View File

@@ -8,6 +8,7 @@ pkgdata_PYTHON = \
_FamilyPrivate.py\
_HasEvent.py\
_HasAttribute.py\
_HasCitation.py \
_HasGallery.py \
_HasIdOf.py\
_HasLDS.py \
@@ -16,7 +17,7 @@ pkgdata_PYTHON = \
_HasNoteRegexp.py\
_HasReferenceCountOf.py\
_HasRelType.py\
_HasSource.py \
_HasSourceCount.py \
_HasTag.py \
__init__.py\
_IsBookmarked.py\

View File

@@ -0,0 +1,61 @@
#
# 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$
"""
Filter rule to match family with a particular citation.
"""
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from 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 = _('Family with the <citation>')
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

View File

@@ -35,12 +35,12 @@ from gen.ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasSourceBase import HasSourceBase
from Filters.Rules._HasSourceCountBase import HasSourceCountBase
#-------------------------------------------------------------------------
# "Families having sources"
#-------------------------------------------------------------------------
class HasSource(HasSourceBase):
class HasSourceCount(HasSourceCountBase):
"""Families with sources"""
name = _('Families with <count> sources')

View File

@@ -3,6 +3,7 @@
#
# Copyright (C) 2002-2007 Donald N. Allingham
# Copyright (C) 2007-2008 Brian G. Matherly
# 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
@@ -41,8 +42,9 @@ from _RegExpIdOf import RegExpIdOf
from _HasNote import HasNote
from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasSource import HasSource
from _HasSourceCount import HasSourceCount
from _HasReferenceCountOf import HasReferenceCountOf
from _HasCitation import HasCitation
from _FamilyPrivate import FamilyPrivate
from _HasAttribute import HasAttribute
from _HasEvent import HasEvent
@@ -69,7 +71,8 @@ editor_rule_list = [
HasNoteRegexp,
HasNoteMatchingSubstringOf,
HasReferenceCountOf,
HasSource,
HasSourceCount,
HasCitation,
FamilyPrivate,
HasEvent,
HasAttribute,

View File

@@ -1,6 +1,6 @@
# This is the src/Filters/Rules level Makefile for Gramps
SUBDIRS = Person Family Event Place Source MediaObject Repository Note
SUBDIRS = Person Family Event Place Source MediaObject Repository Note Citation
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules
@@ -16,6 +16,7 @@ pkgdata_PYTHON = \
_HasNoteRegexBase.py\
_HasNoteSubstrBase.py\
_HasReferenceCountBase.py \
_HasSourceCountBase.py \
_HasSourceBase.py \
_HasTagBase.py \
_HasTextMatchingRegexpOf.py\
@@ -25,9 +26,10 @@ pkgdata_PYTHON = \
_RegExpIdBase.py\
_Rule.py\
_MatchesFilterBase.py\
_MatchesEventFilterBase.py \
_MatchesSourceConfidenceBase.py \
_MatchesSourceFilterBase.py
_MatchesEventFilterBase.py \
_MatchesSourceConfidenceBase.py \
_MatchesSourceFilterBase.py \
_HasCitationBase.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules

View File

@@ -13,6 +13,7 @@ pkgdata_PYTHON = \
_HasAlternateName.py \
_HasAssociation.py \
_HasBirth.py \
_HasCitation.py \
_HasCommonAncestorWith.py \
_HasCommonAncestorWithFilterMatch.py \
_HasDeath.py \
@@ -29,7 +30,7 @@ pkgdata_PYTHON = \
_HasNote.py \
_HasNoteMatchingSubstringOf.py \
_HasRelationship.py \
_HasSource.py \
_HasSourceCount.py \
_HasSourceOf.py \
_HasTag.py \
_HasTextMatchingRegexpOf.py \

View File

@@ -0,0 +1,60 @@
#
# 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$
"""
Filter rule to match persons with a particular citation.
"""
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from 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 = _('People with the <citation>')
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

View File

@@ -35,12 +35,12 @@ from gen.ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasSourceBase import HasSourceBase
from Filters.Rules._HasSourceCountBase import HasSourceCountBase
#-------------------------------------------------------------------------
# "People having sources"
#-------------------------------------------------------------------------
class HasSource(HasSourceBase):
class HasSourceCount(HasSourceCountBase):
"""People with sources"""
name = _('People with <count> sources')

View File

@@ -2,6 +2,7 @@
# 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
@@ -44,7 +45,7 @@ class HasSourceOf(Rule):
labels = [ _('Source ID:') ]
name = _('People with the <source>')
category = _('General filters')
category = _('Citation/source filters')
description = _('Matches people who have a particular source')
def prepare(self,db):
@@ -55,14 +56,22 @@ class HasSourceOf(Rule):
self.nosource = False
try:
self.source_handle = db.get_source_from_gramps_id(self.list[0]).get_handle()
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:
return len(person.get_source_references()) == 0
# 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
return person.has_source_reference(self.source_handle)
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

View File

@@ -2,6 +2,7 @@
# 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
@@ -26,13 +27,15 @@
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
import logging
LOG = logging.getLogger(".citationfilter")
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Utils import get_source_referents
from Utils import get_source_and_citation_referents
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
@@ -179,15 +182,30 @@ class HasTextMatchingSubstringOf(Rule):
# search all sources and match all referents of a matching source
for source in self.db.iter_sources():
match = self.match_object(source)
LOG.debug("cache_sources match %s string %s source %s" %
(match, self.list[0], source.gramps_id))
if not match:
if any(reporef.get_reference_handle() in self.repo_map
for reporef in source.get_reporef_list()
):
match = True
LOG.debug("cache_sources repomatch %s string %s source %s" %
(match, self.list[0], source.gramps_id))
(citation_list, citation_referents_list) = \
get_source_and_citation_referents(source.handle, self.db)
LOG.debug("the_lists %s %s" %
(citation_list, citation_referents_list))
for (citation_handle, refs) in citation_referents_list:
citation = self.db.get_citation_from_handle(citation_handle)
LOG.debug("cache_sources match %s matchcitation %s string %s"
" source %s citation %s" %
(match, self.match_object(citation),
self.list[0], source.gramps_id,
citation.gramps_id))
if match or self.match_object(citation):
# Update the maps to reflect the reference
(person_list, family_list, event_list, place_list,
source_list, media_list, repo_list
) = get_source_referents(source.handle,self.db)
(person_list, family_list, event_list, place_list,
source_list, media_list, repo_list) = refs
self.person_map.update(person_list)
self.family_map.update(family_list)
self.event_map.update(event_list)

View File

@@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
# $Id: _IsRelatedWith.py 18338 2011-10-16 20:21:22Z paul-franklin $
#-------------------------------------------------------------------------
#

View File

@@ -3,6 +3,7 @@
#
# Copyright (C) 2002-2007 Donald N. Allingham
# Copyright (C) 2007-2008 Brian G. Matherly
# 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
@@ -33,6 +34,7 @@ from _HasAlternateName import HasAlternateName
from _HasAssociation import HasAssociation
from _HasAttribute import HasAttribute
from _HasBirth import HasBirth
from _HasCitation import HasCitation
from _HasCommonAncestorWith import HasCommonAncestorWith
from _HasCommonAncestorWithFilterMatch import HasCommonAncestorWithFilterMatch
from _HasDeath import HasDeath
@@ -50,7 +52,7 @@ from _HasNote import HasNote
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasNoteRegexp import HasNoteRegexp
from _HasRelationship import HasRelationship
from _HasSource import HasSource
from _HasSourceCount import HasSourceCount
from _HasSourceOf import HasSourceOf
from _HasTag import HasTag
from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf
@@ -132,12 +134,13 @@ editor_rule_list = [
HasRelationship,
HasDeath,
HasBirth,
HasCitation,
HasEvent,
HasFamilyEvent,
HasAttribute,
HasFamilyAttribute,
HasTag,
HasSource,
HasSourceCount,
HasSourceOf,
HaveAltFamilies,
HavePhotos,

View File

@@ -12,7 +12,6 @@ pkgdata_PYTHON = \
_HasReferenceCountOf.py\
_AllSources.py\
_HasIdOf.py\
_HasSource.py\
_HasNote.py \
_HasNoteRegexp.py\
_HasRepository.py\

View File

@@ -3,6 +3,7 @@
#
# Copyright (C) 2002-2007 Donald N. Allingham
# Copyright (C) 2007-2008 Brian G. Matherly
# 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
@@ -25,6 +26,8 @@
Package providing filter rules for GRAMPS.
"""
from Filters.Rules._HasSourceBase import HasSourceBase as HasSource
from _AllSources import AllSources
from _HasGallery import HasGallery
from _HasIdOf import HasIdOf
@@ -35,7 +38,6 @@ from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasReferenceCountOf import HasReferenceCountOf
from _SourcePrivate import SourcePrivate
from _MatchesFilter import MatchesFilter
from _HasSource import HasSource
from _ChangedSince import ChangedSince
from _HasRepository import HasRepository
from _MatchesTitleSubstringOf import MatchesTitleSubstringOf

View File

@@ -0,0 +1,78 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import DateHandler
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#
# HasCitation
#
#-------------------------------------------------------------------------
class HasCitationBase(Rule):
"""Rule that checks for a citation with a particular value
First parameter is [Volume/page, Date, Confidence]
"""
labels = [ _('Volume/Page:'),
_('Date:'),
_('Confidence:') ]
name = _('Citations matching parameters')
description = _("Matches citations with particular parameters")
category = _('Citation/source filters')
def prepare(self, db):
self.date = None
try:
if self.list[1]:
self.date = DateHandler.parser.parse(self.list[1])
except:
pass
def apply(self,db,citation):
if not self.match_substring(0,citation.get_page()):
return False
if self.date:
if not citation.get_date_object().match(self.date):
return False
if self.list[2]:
if citation.get_confidence_level() < int(self.list[2]):
return False
return True

52
src/Filters/Rules/_HasSourceBase.py Executable file → Normal file
View File

@@ -1,10 +1,8 @@
#
# 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
# 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
@@ -20,9 +18,8 @@
# 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/_HasSourceBase.py
# $Id$
#
#-------------------------------------------------------------------------
#
@@ -39,32 +36,29 @@ from gen.ggettext import gettext as _
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "Objects having sources"
#
# HasSource
#
#-------------------------------------------------------------------------
class HasSourceBase(Rule):
"""Objects having notes"""
"""Rule that checks for a source with a particular value"""
labels = [ _('Number of instances:'), _('Number must be:')]
name = _('Objects with <count> sources')
description = _("Matches objects that have a certain number of sources connected to it")
category = _('General filters')
def prepare(self, db):
# things we want to do just once, not for every handle
if self.list[1] == 'lesser than':
self.count_type = 0
elif self.list[1] == 'greater than':
self.count_type = 2
else:
self.count_type = 1 # "equal to"
labels = [ _('Title:'),
_('Author:'),
_('Publication:') ]
name = _('Sources matching parameters')
description = _("Matches sources with particular parameters")
category = _('Citation/source filters')
self.userSelectedCount = int(self.list[0])
def apply(self,db,source):
if not self.match_substring(0,source.get_title()):
return False
def apply(self, db, obj):
count = len(obj.get_source_references())
if self.count_type == 0: # "lesser than"
return count < self.userSelectedCount
elif self.count_type == 2: # "greater than"
return count > self.userSelectedCount
# "equal to"
return count == self.userSelectedCount
if not self.match_substring(1,source.get_author()):
return False
if not self.match_substring(2,source.get_publication_info()):
return False
return True

View File

@@ -0,0 +1,70 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "Objects having sources"
#-------------------------------------------------------------------------
class HasSourceCountBase(Rule):
"""Objects having sources"""
labels = [ _('Number of instances:'), _('Number must be:')]
name = _('Objects with <count> sources')
description = _("Matches objects that have a certain number of sources "
"connected to it (actually citations are counted)")
category = _('Citation/source filters')
def prepare(self, db):
# things we want to do just once, not for every handle
if self.list[1] == 'lesser than':
self.count_type = 0
elif self.list[1] == 'greater than':
self.count_type = 2
else:
self.count_type = 1 # "equal to"
self.userSelectedCount = int(self.list[0])
def apply(self, db, obj):
count = len(obj.get_citation_list())
if self.count_type == 0: # "lesser than"
return count < self.userSelectedCount
elif self.count_type == 2: # "greater than"
return count > self.userSelectedCount
# "equal to"
return count == self.userSelectedCount

View File

@@ -4,6 +4,7 @@
# Copyright (C) 2011 Jerome Rapinat
# Copyright (C) 2011 Douglas S. Blank
# Copyright (C) 2011 Benny Malengier
# 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
@@ -47,11 +48,12 @@ class MatchesSourceConfidenceBase(Rule):
labels = [_('Confidence level:')]
name = _('Object with at least one direct source >= <confidence level>')
description = _("Matches objects with at least one direct source with confidence level(s)")
category = _('General filters')
category = _('Citation/source filters')
def apply(self, db, obj):
for source in obj.get_source_references():
required_conf = int(self.list[0])
if required_conf <= source.get_confidence_level():
required_conf = int(self.list[0])
for citation_handle in obj.get_citation_list():
citation = db.get_citation_from_handle(citation_handle)
if required_conf <= citation.get_confidence_level():
return True
return False

View File

@@ -2,6 +2,7 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2010 Benny Malengier
# 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
@@ -48,7 +49,7 @@ class MatchesSourceFilterBase(MatchesFilterBase):
name = _('Objects with source matching the <source filter>')
description = _("Matches objects with sources that match the "
"specified source filter name")
category = _('General filters')
category = _('Citation/source filters')
# we want to have this filter show source filters
namespace = 'Source'
@@ -61,9 +62,9 @@ class MatchesSourceFilterBase(MatchesFilterBase):
if self.MSF_filt is None :
return False
sourcelist = [x.ref for x in object.get_source_references()]
for sourcehandle in sourcelist:
#check if source in source filter
for citation_handle in object.get_citation_list():
citation = db.get_citation_from_handle(citation_handle)
sourcehandle = citation.get_reference_handle()
if self.MSF_filt.check(db, sourcehandle):
return True
return False

View File

@@ -2,6 +2,7 @@
# 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
@@ -22,6 +23,46 @@
"""
Package providing filter rules for GRAMPS.
The following filters are provided in Filters/Rules.
Match given values:
_HasCitationBase Citation with a particular value (HasCitation)
also used for Person, Family and Event having a
particular Citation
_HasEventBase Event with a particular value (HasEvent)
also used for Family and Person having a particular
Event
_HasSourceBase Source with a particular value (HasSource)
also used for Citation having a particular Source
Match on sub-objects
_ChangedSinceBase Object changed since date
_HasAttributeBase Object has particular attribute value
_HasGrampsId Object has a specific Gramps Id
_HasNoteRegexBase Object has notes matching regular expression
_HasNoteSubstrBase Object has note containing substring
_HasTagBase Object has a particular tag
_HasTextMatchingRegexpOf Object has text matching regular expression
_HasTextMatchingSubstringOf Object has text containing substring
_IsPrivate Object is marked as private
_MatchesFilterBase Object matches another filter
_RegExpldBase Object has Gramps Id matching regular expression
Match on related objects
_MatchesFilterEventBase Object has an event that matches another filter
_MatchesSourceConfidenceBase Object with specific confidence on direct sources
_MatchesSourceFilterBase Object matches another filter on direct sources
Count based
_HasGalleryBase Object has </>/= number of media objects
_HasLDSBase Object has </>/= number of LDS sub-objects
_HasNoteBase Object has </>/= number of notes
_HasReferenceCountBase Object has </>/= number of references
_HasSourceCountBase Object has </>/= number of sources
_Rule Base rule class
_Everything Match every object in the database
"""
# Need to expose this to be available for filter plugins:
@@ -39,5 +80,5 @@ from Filters.Rules._MatchesSourceConfidenceBase import MatchesSourceConfidenceBa
from Filters.Rules._MatchesSourceFilterBase import MatchesSourceFilterBase
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
from Filters.Rules import (Person, Family, Event, Source, Place, MediaObject,
Repository, Note)
from Filters.Rules import (Person, Family, Event, Source, Citation, Place,
MediaObject, Repository, Note)

View File

@@ -9,6 +9,7 @@ pkgdata_PYTHON = \
_SidebarFilter.py \
_PersonSidebarFilter.py\
_SourceSidebarFilter.py\
_CitationSidebarFilter.py\
_PlaceSidebarFilter.py\
_MediaSidebarFilter.py\
_RepoSidebarFilter.py\

View File

@@ -0,0 +1,164 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Python modules
#
#-------------------------------------------------------------------------
from gen.ggettext import gettext as _
#-------------------------------------------------------------------------
#
# gtk
#
#-------------------------------------------------------------------------
import gtk
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from gui.widgets import MonitoredMenu
import gen.lib
from Filters.SideBar import SidebarFilter
from Filters import GenericFilterFactory, build_filter_model, Rules
from Filters.Rules.Citation import (RegExpIdOf, HasIdOf, HasCitation,
HasNoteMatchingSubstringOf, HasNoteRegexp,
MatchesFilter)
from Utils import confidence
GenericCitationFilter = GenericFilterFactory('Citation')
#-------------------------------------------------------------------------
#
# PersonSidebarFilter class
#
#-------------------------------------------------------------------------
class CitationSidebarFilter(SidebarFilter):
def __init__(self, dbstate, uistate, clicked):
self.clicked_func = clicked
self.filter_id = gtk.Entry()
self.filter_page = gtk.Entry()
self.filter_date = gtk.Entry()
self.filter_conf = gtk.ComboBox()
model = gtk.ListStore(str)
for conf_value in sorted(confidence.keys()):
model.append((confidence[conf_value],))
self.filter_conf.set_model(model)
self.filter_conf.set_active(2) # gen.lib.Citation.CONF_NORMAL
self.filter_note = gtk.Entry()
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
self.generic = gtk.ComboBox()
SidebarFilter.__init__(self, dbstate, uistate, "Citation")
def create_widget(self):
cell = gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.generic.pack_start(cell, True)
self.generic.add_attribute(cell, 'text', 0)
self.on_filters_changed('Citation')
cell = gtk.CellRendererText()
cell.set_property('width', self._FILTER_WIDTH)
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
self.filter_conf.pack_start(cell, True)
self.filter_conf.add_attribute(cell, 'text', 0)
self.add_text_entry(_('ID'), self.filter_id)
self.add_text_entry(_('Volume/Page'), self.filter_page)
self.add_text_entry(_('Date'), self.filter_date)
self.add_entry(_('Confidence'), self.filter_conf)
self.add_text_entry(_('Note'), self.filter_note)
self.add_filter_entry(_('Custom filter'), self.generic)
self.add_entry(None, self.filter_regex)
def clear(self, obj):
self.filter_id.set_text('')
self.filter_page.set_text('')
self.filter_date.set_text('')
self.filter_conf.set_active(2)
self.filter_note.set_text('')
self.generic.set_active(0)
def get_filter(self):
gid = unicode(self.filter_id.get_text()).strip()
page = unicode(self.filter_page.get_text()).strip()
date = unicode(self.filter_date.get_text()).strip()
model = self.filter_conf.get_model()
node = self.filter_conf.get_active_iter()
conf_name = model.get_value(node, 0) # The value is actually the text
conf = 2
for i in confidence.keys():
if confidence[i] == conf_name:
conf = i
break
# conf = self.citn.get_confidence_level()
note = unicode(self.filter_note.get_text()).strip()
regex = self.filter_regex.get_active()
gen = self.generic.get_active() > 0
empty = not (gid or page or date or conf or note or regex or gen)
if empty:
generic_filter = None
else:
generic_filter = GenericCitationFilter()
if gid:
if regex:
rule = RegExpIdOf([gid])
else:
rule = HasIdOf([gid])
generic_filter.add_rule(rule)
rule = HasCitation([page, date, conf], use_regex=regex)
generic_filter.add_rule(rule)
if note:
if regex:
rule = HasNoteRegexp([note])
else:
rule = HasNoteMatchingSubstringOf([note])
generic_filter.add_rule(rule)
if self.generic.get_active() != 0:
model = self.generic.get_model()
node = self.generic.get_active_iter()
obj = unicode(model.get_value(node, 0))
rule = MatchesFilter([obj])
generic_filter.add_rule(rule)
return generic_filter
def on_filters_changed(self, name_space):
if name_space == 'Citation':
all_filter = GenericCitationFilter()
all_filter.set_name(_("None"))
all_filter.add_rule(Rules.Citation.AllCitations([]))
self.generic.set_model(build_filter_model('Citation', [all_filter]))
self.generic.set_active(0)

View File

@@ -2,6 +2,7 @@
# 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
@@ -29,6 +30,7 @@ from _PersonSidebarFilter import PersonSidebarFilter
from _FamilySidebarFilter import FamilySidebarFilter
from _EventSidebarFilter import EventSidebarFilter
from _SourceSidebarFilter import SourceSidebarFilter
from _CitationSidebarFilter import CitationSidebarFilter
from _PlaceSidebarFilter import PlaceSidebarFilter
from _MediaSidebarFilter import MediaSidebarFilter
from _RepoSidebarFilter import RepoSidebarFilter

View File

@@ -2,6 +2,7 @@
# 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
@@ -276,6 +277,20 @@ class GenericSourceFilter(GenericFilter):
def find_from_handle(self, db, handle):
return db.get_source_from_handle(handle)
class GenericCitationFilter(GenericFilter):
def __init__(self, source=None):
GenericFilter.__init__(self, source)
def get_cursor(self, db):
return db.get_citation_cursor()
def make_obj(self):
return gen.lib.Citation()
def find_from_handle(self, db, handle):
return db.get_citation_from_handle(handle)
class GenericPlaceFilter(GenericFilter):
def __init__(self, source=None):
@@ -342,6 +357,8 @@ def GenericFilterFactory(namespace):
return GenericEventFilter
elif namespace == 'Source':
return GenericSourceFilter
elif namespace == 'Citation':
return GenericCitationFilter
elif namespace == 'Place':
return GenericPlaceFilter
elif namespace == 'MediaObject':