Updated Filters and Filters/Rules for citations

* renamed HasSourceBase to HasSourceCountBase to reflect function, and because HasSourceBase is changed to be more widely used
* consequent renaming of filters for various object types
* changed source filters to a new 'Citation/source filters' category
* added Citation/_HasSource to check whether Citation refers to a Source with particular properties
* added Person/_HasCitation, Event/_HasCitation and Family/_HasCitation to check whether object refers to a Citation with particular properties
* updated Citation/_MatchesSourceFilter
* updated Rules/_MatchesSourceConfidenceBase
* updated Rules/_MatchesSourceFilterBase
* updated Citation object and citationbase.py for source references
* updated Person/_HasSourceOf 

* updated comments in Filters/Rules/__init__.py to document how the various rules are used.


svn: r18339
This commit is contained in:
Tim G L Lyons 2011-10-16 21:09:49 +00:00
parent f35cb08aff
commit 5e0c4d074a
28 changed files with 425 additions and 90 deletions

View File

@ -13,6 +13,7 @@ pkgdata_PYTHON = \
_HasNoteMatchingSubstringOf.py \
_HasNoteRegexp.py \
_HasReferenceCountOf.py \
_HasSource.py \
_MatchesFilter.py \
_MatchesPageSubstringOf.py \
_MatchesRepositoryFilter.py \

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

@ -34,23 +34,36 @@ from gen.ggettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules import MatchesSourceFilterBase
from Filters.Rules import MatchesFilterBase
#-------------------------------------------------------------------------
#
# MatchesFilter
#
#-------------------------------------------------------------------------
class MatchesSourceFilter(MatchesSourceFilterBase):
class MatchesSourceFilter(MatchesFilterBase):
"""
Rule that checks against another filter.
"""
labels = [_('Source filter name:')]
name = _('Events with source matching the <source filter>')
description = _("Matches events with sources that match the "
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

@ -37,6 +37,7 @@ 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
@ -53,6 +54,7 @@ editor_rule_list = [
HasNoteMatchingSubstringOf,
HasNoteRegexp,
HasReferenceCountOf,
HasSource,
MatchesFilter,
MatchesPageSubstringOf,
MatchesRepositoryFilter,

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

@ -20,6 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
#-------------------------------------------------------------------------
#
# Standard Python modules
@ -32,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

@ -49,7 +49,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

@ -32,11 +32,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 +53,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

@ -41,8 +41,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 +70,8 @@ editor_rule_list = [
HasNoteRegexp,
HasNoteMatchingSubstringOf,
HasReferenceCountOf,
HasSource,
HasSourceCount,
HasCitation,
FamilyPrivate,
HasEvent,
HasAttribute,

View File

@ -16,6 +16,7 @@ pkgdata_PYTHON = \
_HasNoteRegexBase.py\
_HasNoteSubstrBase.py\
_HasReferenceCountBase.py \
_HasSourceCountBase.py \
_HasSourceBase.py \
_HasTagBase.py \
_HasTextMatchingRegexpOf.py\

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

@ -44,7 +44,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 +55,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

@ -33,6 +33,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 +51,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
@ -131,12 +132,13 @@ editor_rule_list = [
HasRelationship,
HasDeath,
HasBirth,
HasCitation,
HasEvent,
HasFamilyEvent,
HasAttribute,
HasFamilyAttribute,
HasTag,
HasSource,
HasSourceCount,
HasSourceOf,
HaveAltFamilies,
HavePhotos,

View File

@ -25,6 +25,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 +37,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

@ -53,7 +53,7 @@ class HasCitationBase(Rule):
_('Confidence:') ]
name = _('Citations matching parameters')
description = _("Matches citations with particular parameters")
category = _('General filters')
category = _('Citation/source filters')
def prepare(self, db):
self.date = None

49
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
@ -38,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

@ -44,11 +44,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

@ -48,7 +48,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 +61,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

@ -22,6 +22,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:

View File

@ -181,6 +181,8 @@ class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
"""
return self.media_list
# FIXME: get_sourceRef_child_list needs to be removed
# def get_sourcref_child_list(self):
# """
# Return the list of child secondary objects that may refer sources.
@ -193,16 +195,6 @@ class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
# """
# return []
def get_source_references(self) :
"""
Return the list of source references associated with the object.
:returns: Returns the list of :class:`~gen.lib.srcref.SourceRef` objects associated with
the object.
:rtype: list
"""
return [self.source_handle]
def get_note_child_list(self):
"""
Return the list of child secondary objects that may refer notes.
@ -236,6 +228,11 @@ class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
ret += [('Source', self.get_reference_handle())]
return ret
# FIXME: Remove all has_source_refernce and consequently all
# get_sourceref_child_list, because these seem to be only used in the filter
# _HasSourceOf and mergesource, and it is better to make the test directly,
# because, only citations refer to sources, and they have only one reference.
# need to check remove and replace source reference.
def has_source_reference(self, src_handle) :
"""
Return True if any of the child objects has reference to this source

View File

@ -137,6 +137,20 @@ class CitationBase(object):
"""
return self.citation_list
def get_all_citation_lists(self):
"""
Return the list of :class:`~gen.lib.citation.Citation` handles
associated with the object or with child objects.
:returns: The list of :class:`~gen.lib.citation.Citation` handles
:rtype: list
"""
list = self.citation_list
for item in self.get_citation_child_list():
list += item.get_citation_list()
return list
def has_citation_reference(self, citation_handle):
"""
Return True if the object or any of its child objects has reference