Citation filters
svn: r18182
This commit is contained in:
parent
21e402fc6f
commit
5719832f36
32
src/Filters/Rules/Citation/Makefile.am
Normal file
32
src/Filters/Rules/Citation/Makefile.am
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
# 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 \
|
||||||
|
_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));
|
47
src/Filters/Rules/Citation/_AllCitations.py
Normal file
47
src/Filters/Rules/Citation/_AllCitations.py
Normal 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')
|
50
src/Filters/Rules/Citation/_ChangedSince.py
Normal file
50
src/Filters/Rules/Citation/_ChangedSince.py
Normal 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.")
|
45
src/Filters/Rules/Citation/_CitationPrivate.py
Normal file
45
src/Filters/Rules/Citation/_CitationPrivate.py
Normal 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")
|
47
src/Filters/Rules/Citation/_HasGallery.py
Executable file
47
src/Filters/Rules/Citation/_HasGallery.py
Executable 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")
|
47
src/Filters/Rules/Citation/_HasIdOf.py
Normal file
47
src/Filters/Rules/Citation/_HasIdOf.py
Normal 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")
|
48
src/Filters/Rules/Citation/_HasNote.py
Executable file
48
src/Filters/Rules/Citation/_HasNote.py
Executable 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")
|
47
src/Filters/Rules/Citation/_HasNoteMatchingSubstringOf.py
Normal file
47
src/Filters/Rules/Citation/_HasNoteMatchingSubstringOf.py
Normal 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")
|
||||||
|
|
45
src/Filters/Rules/Citation/_HasNoteRegexp.py
Normal file
45
src/Filters/Rules/Citation/_HasNoteRegexp.py
Normal 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")
|
46
src/Filters/Rules/Citation/_HasReferenceCountOf.py
Normal file
46
src/Filters/Rules/Citation/_HasReferenceCountOf.py
Normal 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")
|
||||||
|
|
48
src/Filters/Rules/Citation/_MatchesFilter.py
Normal file
48
src/Filters/Rules/Citation/_MatchesFilter.py
Normal 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'
|
54
src/Filters/Rules/Citation/_MatchesPageSubstringOf.py
Normal file
54
src/Filters/Rules/Citation/_MatchesPageSubstringOf.py
Normal 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
|
72
src/Filters/Rules/Citation/_MatchesRepositoryFilter.py
Normal file
72
src/Filters/Rules/Citation/_MatchesRepositoryFilter.py
Normal 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
|
56
src/Filters/Rules/Citation/_MatchesSourceFilter.py
Normal file
56
src/Filters/Rules/Citation/_MatchesSourceFilter.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#
|
||||||
|
# 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 MatchesSourceFilterBase
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# MatchesFilter
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
class MatchesSourceFilter(MatchesSourceFilterBase):
|
||||||
|
"""
|
||||||
|
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 "
|
||||||
|
"specified source filter name")
|
||||||
|
category = _('General filters')
|
||||||
|
|
||||||
|
# we want to have this filter show source filters
|
||||||
|
namespace = 'Source'
|
51
src/Filters/Rules/Citation/_RegExpIdOf.py
Normal file
51
src/Filters/Rules/Citation/_RegExpIdOf.py
Normal 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")
|
61
src/Filters/Rules/Citation/__init__.py
Normal file
61
src/Filters/Rules/Citation/__init__.py
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#
|
||||||
|
# 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 _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,
|
||||||
|
MatchesFilter,
|
||||||
|
MatchesPageSubstringOf,
|
||||||
|
MatchesRepositoryFilter,
|
||||||
|
MatchesSourceFilter,
|
||||||
|
RegExpIdOf
|
||||||
|
]
|
@ -25,9 +25,10 @@ pkgdata_PYTHON = \
|
|||||||
_RegExpIdBase.py\
|
_RegExpIdBase.py\
|
||||||
_Rule.py\
|
_Rule.py\
|
||||||
_MatchesFilterBase.py\
|
_MatchesFilterBase.py\
|
||||||
_MatchesEventFilterBase.py \
|
_MatchesEventFilterBase.py \
|
||||||
_MatchesSourceConfidenceBase.py \
|
_MatchesSourceConfidenceBase.py \
|
||||||
_MatchesSourceFilterBase.py
|
_MatchesSourceFilterBase.py \
|
||||||
|
_HasCitationBase.py
|
||||||
|
|
||||||
|
|
||||||
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules
|
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules
|
||||||
|
78
src/Filters/Rules/_HasCitationBase.py
Normal file
78
src/Filters/Rules/_HasCitationBase.py
Normal 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 = _('General 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
|
@ -20,6 +20,8 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Standard Python modules
|
# Standard Python modules
|
||||||
|
@ -20,6 +20,8 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Standard Python modules
|
# Standard Python modules
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Standard Python modules
|
# Standard Python modules
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# $Id$
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Standard Python modules
|
# Standard Python modules
|
||||||
|
@ -39,5 +39,5 @@ from Filters.Rules._MatchesSourceConfidenceBase import MatchesSourceConfidenceBa
|
|||||||
from Filters.Rules._MatchesSourceFilterBase import MatchesSourceFilterBase
|
from Filters.Rules._MatchesSourceFilterBase import MatchesSourceFilterBase
|
||||||
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
|
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
|
||||||
|
|
||||||
from Filters.Rules import (Person, Family, Event, Source, Place, MediaObject,
|
from Filters.Rules import (Person, Family, Event, Source, Citation, Place,
|
||||||
Repository, Note)
|
MediaObject, Repository, Note)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#
|
#
|
||||||
# Gramps - a GTK+/GNOME based genealogy program
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
#
|
#
|
||||||
|
# Copyright (C) 2002-2006 Donald N. Allingham
|
||||||
# Copyright (C) 2011 Tim G L Lyons
|
# Copyright (C) 2011 Tim G L Lyons
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
@ -39,13 +40,15 @@ import gtk
|
|||||||
# GRAMPS modules
|
# GRAMPS modules
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
from gui.widgets import MonitoredMenu
|
||||||
|
import gen.lib
|
||||||
from Filters.SideBar import SidebarFilter
|
from Filters.SideBar import SidebarFilter
|
||||||
from Filters import GenericFilterFactory, build_filter_model, Rules
|
from Filters import GenericFilterFactory, build_filter_model, Rules
|
||||||
from Filters.Rules.Source import (RegExpIdOf, HasIdOf, HasSource,
|
from Filters.Rules.Citation import (RegExpIdOf, HasIdOf, HasCitation,
|
||||||
HasNoteMatchingSubstringOf, HasNoteRegexp,
|
HasNoteMatchingSubstringOf, HasNoteRegexp,
|
||||||
MatchesFilter)
|
MatchesFilter)
|
||||||
# FIXME: need to add Citation filter rules.
|
from Utils import confidence
|
||||||
GenericSourceFilter = GenericFilterFactory('Citation')
|
GenericCitationFilter = GenericFilterFactory('Citation')
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# PersonSidebarFilter class
|
# PersonSidebarFilter class
|
||||||
@ -56,16 +59,19 @@ class CitationSidebarFilter(SidebarFilter):
|
|||||||
def __init__(self, dbstate, uistate, clicked):
|
def __init__(self, dbstate, uistate, clicked):
|
||||||
self.clicked_func = clicked
|
self.clicked_func = clicked
|
||||||
self.filter_id = gtk.Entry()
|
self.filter_id = gtk.Entry()
|
||||||
self.filter_title = gtk.Entry()
|
self.filter_page = gtk.Entry()
|
||||||
self.filter_author = gtk.Entry()
|
self.filter_date = gtk.Entry()
|
||||||
self.filter_pub = gtk.Entry()
|
|
||||||
|
self.citn = gen.lib.Citation()
|
||||||
|
self.filter_conf = gtk.ComboBox()
|
||||||
|
|
||||||
self.filter_note = gtk.Entry()
|
self.filter_note = gtk.Entry()
|
||||||
|
|
||||||
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
|
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
|
||||||
|
|
||||||
self.generic = gtk.ComboBox()
|
self.generic = gtk.ComboBox()
|
||||||
|
|
||||||
SidebarFilter.__init__(self, dbstate, uistate, "Source")
|
SidebarFilter.__init__(self, dbstate, uistate, "Citation")
|
||||||
|
|
||||||
def create_widget(self):
|
def create_widget(self):
|
||||||
cell = gtk.CellRendererText()
|
cell = gtk.CellRendererText()
|
||||||
@ -73,38 +79,53 @@ class CitationSidebarFilter(SidebarFilter):
|
|||||||
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
|
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
|
||||||
self.generic.pack_start(cell, True)
|
self.generic.pack_start(cell, True)
|
||||||
self.generic.add_attribute(cell, 'text', 0)
|
self.generic.add_attribute(cell, 'text', 0)
|
||||||
self.on_filters_changed('Source')
|
self.on_filters_changed('Citation')
|
||||||
|
|
||||||
self.add_text_entry(_('ID'), self.filter_id)
|
self.add_text_entry(_('ID'), self.filter_id)
|
||||||
self.add_text_entry(_('Title'), self.filter_title)
|
self.add_text_entry(_('Volume/Page'), self.filter_page)
|
||||||
self.add_text_entry(_('Author'), self.filter_author)
|
self.add_text_entry(_('Date'), self.filter_date)
|
||||||
self.add_text_entry(_('Publication'), self.filter_pub)
|
# FIXME: The confidence combo-box is not populated with any entries.
|
||||||
|
# I have no idea why this should be, as the code here seems
|
||||||
|
# entirely analogous to src/gui/editors/editcitation,
|
||||||
|
# which itself is derived from src/gui/editors/editsourceref.py
|
||||||
|
# and edit citation displays the confidence selectors correctly.
|
||||||
|
# There is some different code in src/gui/filtereditor.py.
|
||||||
|
self.type_mon = MonitoredMenu(
|
||||||
|
self.filter_conf,
|
||||||
|
self.citn.set_confidence_level,
|
||||||
|
self.citn.get_confidence_level, [
|
||||||
|
(_('Very Low'), gen.lib.Citation.CONF_VERY_LOW),
|
||||||
|
(_('Low'), gen.lib.Citation.CONF_LOW),
|
||||||
|
(_('Normal'), gen.lib.Citation.CONF_NORMAL),
|
||||||
|
(_('High'), gen.lib.Citation.CONF_HIGH),
|
||||||
|
(_('Very High'), gen.lib.Citation.CONF_VERY_HIGH)])
|
||||||
|
self.add_combo_entry(_('Confidence'), self.filter_conf)
|
||||||
self.add_text_entry(_('Note'), self.filter_note)
|
self.add_text_entry(_('Note'), self.filter_note)
|
||||||
self.add_filter_entry(_('Custom filter'), self.generic)
|
self.add_filter_entry(_('Custom filter'), self.generic)
|
||||||
self.add_entry(None, self.filter_regex)
|
self.add_entry(None, self.filter_regex)
|
||||||
|
|
||||||
def clear(self, obj):
|
def clear(self, obj):
|
||||||
self.filter_id.set_text('')
|
self.filter_id.set_text('')
|
||||||
self.filter_title.set_text('')
|
self.filter_page.set_text('')
|
||||||
self.filter_author.set_text('')
|
self.filter_date.set_text('')
|
||||||
self.filter_pub.set_text('')
|
self.filter_conf.set_active(0)
|
||||||
self.filter_note.set_text('')
|
self.filter_note.set_text('')
|
||||||
self.generic.set_active(0)
|
self.generic.set_active(0)
|
||||||
|
|
||||||
def get_filter(self):
|
def get_filter(self):
|
||||||
gid = unicode(self.filter_id.get_text()).strip()
|
gid = unicode(self.filter_id.get_text()).strip()
|
||||||
title = unicode(self.filter_title.get_text()).strip()
|
page = unicode(self.filter_page.get_text()).strip()
|
||||||
author = unicode(self.filter_author.get_text()).strip()
|
date = unicode(self.filter_date.get_text()).strip()
|
||||||
pub = unicode(self.filter_pub.get_text()).strip()
|
conf = self.citn.get_confidence_level()
|
||||||
note = unicode(self.filter_note.get_text()).strip()
|
note = unicode(self.filter_note.get_text()).strip()
|
||||||
regex = self.filter_regex.get_active()
|
regex = self.filter_regex.get_active()
|
||||||
gen = self.generic.get_active() > 0
|
gen = self.generic.get_active() > 0
|
||||||
|
|
||||||
empty = not (gid or title or author or pub or note or regex or gen)
|
empty = not (gid or page or date or conf or note or regex or gen)
|
||||||
if empty:
|
if empty:
|
||||||
generic_filter = None
|
generic_filter = None
|
||||||
else:
|
else:
|
||||||
generic_filter = GenericSourceFilter()
|
generic_filter = GenericCitationFilter()
|
||||||
if gid:
|
if gid:
|
||||||
if regex:
|
if regex:
|
||||||
rule = RegExpIdOf([gid])
|
rule = RegExpIdOf([gid])
|
||||||
@ -112,7 +133,7 @@ class CitationSidebarFilter(SidebarFilter):
|
|||||||
rule = HasIdOf([gid])
|
rule = HasIdOf([gid])
|
||||||
generic_filter.add_rule(rule)
|
generic_filter.add_rule(rule)
|
||||||
|
|
||||||
rule = HasSource([title, author, pub], use_regex=regex)
|
rule = HasCitation([page, date, conf], use_regex=regex)
|
||||||
generic_filter.add_rule(rule)
|
generic_filter.add_rule(rule)
|
||||||
|
|
||||||
if note:
|
if note:
|
||||||
@ -132,9 +153,9 @@ class CitationSidebarFilter(SidebarFilter):
|
|||||||
return generic_filter
|
return generic_filter
|
||||||
|
|
||||||
def on_filters_changed(self, name_space):
|
def on_filters_changed(self, name_space):
|
||||||
if name_space == 'Source':
|
if name_space == 'Citation':
|
||||||
all_filter = GenericSourceFilter()
|
all_filter = GenericCitationFilter()
|
||||||
all_filter.set_name(_("None"))
|
all_filter.set_name(_("None"))
|
||||||
all_filter.add_rule(Rules.Source.AllSources([]))
|
all_filter.add_rule(Rules.Citation.AllCitations([]))
|
||||||
self.generic.set_model(build_filter_model('Source', [all_filter]))
|
self.generic.set_model(build_filter_model('Citation', [all_filter]))
|
||||||
self.generic.set_active(0)
|
self.generic.set_active(0)
|
||||||
|
@ -132,6 +132,15 @@ class SidebarFilter(DbGUIElement):
|
|||||||
xoptions=gtk.FILL, yoptions=0)
|
xoptions=gtk.FILL, yoptions=0)
|
||||||
self.position += 1
|
self.position += 1
|
||||||
|
|
||||||
|
def add_combo_entry(self, name, widget):
|
||||||
|
if name:
|
||||||
|
self.table.attach(widgets.BasicLabel(name),
|
||||||
|
1, 2, self.position, self.position+1,
|
||||||
|
xoptions=gtk.FILL, yoptions=0)
|
||||||
|
self.table.attach(widget, 2, 4, self.position, self.position+1,
|
||||||
|
xoptions=gtk.FILL|gtk.EXPAND, yoptions=0)
|
||||||
|
self.position += 1
|
||||||
|
|
||||||
def on_filters_changed(self, namespace):
|
def on_filters_changed(self, namespace):
|
||||||
"""
|
"""
|
||||||
Called when filters are changed.
|
Called when filters are changed.
|
||||||
|
@ -277,6 +277,20 @@ class GenericSourceFilter(GenericFilter):
|
|||||||
def find_from_handle(self, db, handle):
|
def find_from_handle(self, db, handle):
|
||||||
return db.get_source_from_handle(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):
|
class GenericPlaceFilter(GenericFilter):
|
||||||
|
|
||||||
def __init__(self, source=None):
|
def __init__(self, source=None):
|
||||||
@ -343,6 +357,8 @@ def GenericFilterFactory(namespace):
|
|||||||
return GenericEventFilter
|
return GenericEventFilter
|
||||||
elif namespace == 'Source':
|
elif namespace == 'Source':
|
||||||
return GenericSourceFilter
|
return GenericSourceFilter
|
||||||
|
elif namespace == 'Citation':
|
||||||
|
return GenericCitationFilter
|
||||||
elif namespace == 'Place':
|
elif namespace == 'Place':
|
||||||
return GenericPlaceFilter
|
return GenericPlaceFilter
|
||||||
elif namespace == 'MediaObject':
|
elif namespace == 'MediaObject':
|
||||||
|
@ -193,6 +193,16 @@ class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
|
|||||||
# """
|
# """
|
||||||
# return []
|
# 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):
|
def get_note_child_list(self):
|
||||||
"""
|
"""
|
||||||
Return the list of child secondary objects that may refer notes.
|
Return the list of child secondary objects that may refer notes.
|
||||||
|
@ -85,6 +85,7 @@ _TITLES = {
|
|||||||
'MediaObject' : _('Media Object Filters'),
|
'MediaObject' : _('Media Object Filters'),
|
||||||
'Repository' : _('Repository Filters'),
|
'Repository' : _('Repository Filters'),
|
||||||
'Note' : _('Note Filters'),
|
'Note' : _('Note Filters'),
|
||||||
|
'Citation' : _('Citation Filters'),
|
||||||
}
|
}
|
||||||
|
|
||||||
_name2typeclass = {
|
_name2typeclass = {
|
||||||
@ -293,6 +294,7 @@ class MyID(gtk.HBox):
|
|||||||
'MediaObject' : _('Media Object'),
|
'MediaObject' : _('Media Object'),
|
||||||
'Repository' : _('Repository'),
|
'Repository' : _('Repository'),
|
||||||
'Note' : _('Note'),
|
'Note' : _('Note'),
|
||||||
|
'Citation' : _('Citation'),
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, dbstate, uistate, track, namespace='Person'):
|
def __init__(self, dbstate, uistate, track, namespace='Person'):
|
||||||
@ -345,6 +347,9 @@ class MyID(gtk.HBox):
|
|||||||
elif self.namespace == 'Source':
|
elif self.namespace == 'Source':
|
||||||
source = self.db.get_source_from_gramps_id(gramps_id)
|
source = self.db.get_source_from_gramps_id(gramps_id)
|
||||||
name = source.get_title()
|
name = source.get_title()
|
||||||
|
elif self.namespace == 'Citation':
|
||||||
|
citation = self.db.get_citation_from_gramps_id(gramps_id)
|
||||||
|
name = citation.get_page()
|
||||||
elif self.namespace == 'MediaObject':
|
elif self.namespace == 'MediaObject':
|
||||||
obj = self.db.get_object_from_gramps_id(gramps_id)
|
obj = self.db.get_object_from_gramps_id(gramps_id)
|
||||||
name = obj.get_path()
|
name = obj.get_path()
|
||||||
@ -461,6 +466,8 @@ class EditRule(ManagedWindow.ManagedWindow):
|
|||||||
class_list = Rules.Event.editor_rule_list
|
class_list = Rules.Event.editor_rule_list
|
||||||
elif self.namespace == 'Source':
|
elif self.namespace == 'Source':
|
||||||
class_list = Rules.Source.editor_rule_list
|
class_list = Rules.Source.editor_rule_list
|
||||||
|
elif self.namespace == 'Citation':
|
||||||
|
class_list = Rules.Citation.editor_rule_list
|
||||||
elif self.namespace == 'Place':
|
elif self.namespace == 'Place':
|
||||||
class_list = Rules.Place.editor_rule_list
|
class_list = Rules.Place.editor_rule_list
|
||||||
elif self.namespace == 'MediaObject':
|
elif self.namespace == 'MediaObject':
|
||||||
@ -915,6 +922,10 @@ class ShowResults(ManagedWindow.ManagedWindow):
|
|||||||
source = self.db.get_source_from_handle(handle)
|
source = self.db.get_source_from_handle(handle)
|
||||||
name = source.get_title()
|
name = source.get_title()
|
||||||
gid = source.get_gramps_id()
|
gid = source.get_gramps_id()
|
||||||
|
elif self.namespace == 'Citation':
|
||||||
|
citation = self.db.get_citation_from_handle(handle)
|
||||||
|
name = citation.get_title()
|
||||||
|
gid = citation.get_gramps_id()
|
||||||
elif self.namespace == 'Place':
|
elif self.namespace == 'Place':
|
||||||
place = self.db.get_place_from_handle(handle)
|
place = self.db.get_place_from_handle(handle)
|
||||||
name = place.get_title()
|
name = place.get_title()
|
||||||
@ -946,6 +957,8 @@ class ShowResults(ManagedWindow.ManagedWindow):
|
|||||||
sortname = self.db.get_event_from_handle(handle).get_description()
|
sortname = self.db.get_event_from_handle(handle).get_description()
|
||||||
elif self.namespace == 'Source':
|
elif self.namespace == 'Source':
|
||||||
sortname = self.db.get_source_from_handle(handle).get_title()
|
sortname = self.db.get_source_from_handle(handle).get_title()
|
||||||
|
elif self.namespace == 'Citation':
|
||||||
|
sortname = self.db.get_citation_from_handle(handle).get_title()
|
||||||
elif self.namespace == 'Place':
|
elif self.namespace == 'Place':
|
||||||
sortname = self.db.get_place_from_handle(handle).get_title()
|
sortname = self.db.get_place_from_handle(handle).get_title()
|
||||||
elif self.namespace == 'MediaObject':
|
elif self.namespace == 'MediaObject':
|
||||||
@ -1133,6 +1146,8 @@ class FilterEditor(ManagedWindow.ManagedWindow):
|
|||||||
return self.db.get_event_handles()
|
return self.db.get_event_handles()
|
||||||
elif self.namespace == 'Source':
|
elif self.namespace == 'Source':
|
||||||
return self.db.get_source_handles()
|
return self.db.get_source_handles()
|
||||||
|
elif self.namespace == 'Citation':
|
||||||
|
return self.db.get_citation_handles()
|
||||||
elif self.namespace == 'Place':
|
elif self.namespace == 'Place':
|
||||||
return self.db.iter_place_handles()
|
return self.db.iter_place_handles()
|
||||||
elif self.namespace == 'MediaObject':
|
elif self.namespace == 'MediaObject':
|
||||||
|
@ -419,6 +419,7 @@ class BaseCitationView(ListView):
|
|||||||
def get_default_gramplets(self):
|
def get_default_gramplets(self):
|
||||||
"""
|
"""
|
||||||
Define the default gramplets for the sidebar and bottombar.
|
Define the default gramplets for the sidebar and bottombar.
|
||||||
|
This is overridden for the tree view to give 'Source Filter'
|
||||||
"""
|
"""
|
||||||
return (("Citation Filter",),
|
return (("Citation Filter",),
|
||||||
("Citation Gallery",
|
("Citation Gallery",
|
||||||
|
Loading…
Reference in New Issue
Block a user