* src/Filters/Rules/*: Add object-specific rules.

svn: r6529
This commit is contained in:
Alex Roitman 2006-05-03 06:29:07 +00:00
parent 5e85cd3c91
commit 2dd9893045
94 changed files with 1085 additions and 550 deletions

View File

@ -3,6 +3,8 @@
* data/gramps.schemas.in: add family-warn back in
2006-05-02 Alex Roitman <shura@gramps-project.org>
* src/Filters/Rules/*: Add object-specific rules.
* src/GrampsWidgets.py (IconButton): Replace event box with button.
* src/GrampsWidgets.py (WarnButton): Replace event box with button.

View File

@ -348,29 +348,29 @@ class PersonView(PageView.PersonNavView):
Builds the default filters and add them to the filter menu.
"""
default_filters = [
[Rules.Everyone, []],
[Rules.IsFemale, []],
[Rules.IsMale, []],
[Rules.HasUnknownGender, []],
[Rules.Disconnected, []],
[Rules.SearchName, ['']],
[Rules.HaveAltFamilies, []],
[Rules.HavePhotos, []],
[Rules.IncompleteNames, []],
[Rules.HaveChildren, []],
[Rules.NeverMarried, []],
[Rules.MultipleMarriages, []],
[Rules.NoBirthdate, []],
[Rules.PersonWithIncompleteEvent, []],
[Rules.FamilyWithIncompleteEvent, []],
[Rules.ProbablyAlive, ['']],
[Rules.PeoplePrivate, []],
[Rules.IsWitness, ['','']],
[Rules.HasTextMatchingSubstringOf, ['',0,0]],
[Rules.HasTextMatchingRegexpOf, ['',0,1]],
[Rules.HasNote, []],
[Rules.HasNoteMatchingSubstringOf, ['']],
[Rules.IsFemale, []],
[Rules.Person.Everyone, []],
[Rules.Person.IsFemale, []],
[Rules.Person.IsMale, []],
[Rules.Person.HasUnknownGender, []],
[Rules.Person.Disconnected, []],
[Rules.Person.SearchName, ['']],
[Rules.Person.HaveAltFamilies, []],
[Rules.Person.HavePhotos, []],
[Rules.Person.IncompleteNames, []],
[Rules.Person.HaveChildren, []],
[Rules.Person.NeverMarried, []],
[Rules.Person.MultipleMarriages, []],
[Rules.Person.NoBirthdate, []],
[Rules.Person.PersonWithIncompleteEvent, []],
[Rules.Person.FamilyWithIncompleteEvent, []],
[Rules.Person.ProbablyAlive, ['']],
[Rules.Person.PeoplePrivate, []],
[Rules.Person.IsWitness, ['','']],
[Rules.Person.HasTextMatchingSubstringOf, ['',0,0]],
[Rules.Person.HasTextMatchingRegexpOf, ['',0,1]],
[Rules.Person.HasNote, []],
[Rules.Person.HasNoteMatchingSubstringOf, ['']],
[Rules.Person.IsFemale, []],
]
self.generic_filter_widget.setup_filter( default_filters, "person")

View File

@ -0,0 +1,18 @@
# This is the src/Filters/Rules/Event level Makefile for Gramps
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Event
pkgdata_PYTHON = \
__init__.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Event
pkgpythondir = @pkgpythondir@/Filters/Rules/Event
# 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,27 @@
#
# 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: __init__.py 6521 2006-05-03 01:02:54Z rshura $
"""
Package providing filter rules for GRAMPS.
"""
__author__ = "Don Allingham"

View File

@ -0,0 +1,18 @@
# This is the src/Filters/Rules/Family level Makefile for Gramps
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Family
pkgdata_PYTHON = \
__init__.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Family
pkgpythondir = @pkgpythondir@/Filters/Rules/Family
# 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,27 @@
#
# 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: __init__.py 6521 2006-05-03 01:02:54Z rshura $
"""
Package providing filter rules for GRAMPS.
"""
__author__ = "Don Allingham"

View File

@ -1,64 +1,12 @@
# This is the src/Filters/Rules level Makefile for Gramps
SUBDIRS = Person Family Event Place Source Media Repository
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules
pkgdata_PYTHON = \
_Disconnected.py \
_Everyone.py \
_FamilyWithIncompleteEvent.py \
_HasAttribute.py \
_HasBirth.py \
_HasCommonAncestorWith.py \
_HasCommonAncestorWithFilterMatch.py \
_HasCompleteRecord.py \
_HasDeath.py \
_HasEvent.py \
_HasFamilyAttribute.py \
_HasFamilyEvent.py \
_HasIdOf.py \
_HasNameOf.py \
_HasNote.py \
_HasNoteMatchingSubstringOf.py \
_HasRelationship.py \
_HasSourceOf.py \
_HasTextMatchingRegexpOf.py \
_HasTextMatchingSubstringOf.py \
_HasUnknownGender.py \
_HaveAltFamilies.py \
_HaveChildren.py \
_HavePhotos.py \
_IncompleteNames.py \
_IsAncestorOf.py \
_IsAncestorOfFilterMatch.py \
_IsBookmarked.py \
_IsChildOfFilterMatch.py \
_IsDefaultPerson.py \
_IsDescendantFamilyOf.py \
_IsDescendantOf.py \
_IsDescendantOfFilterMatch.py \
_IsFemale.py \
_IsLessThanNthGenerationAncestorOf.py \
_IsLessThanNthGenerationAncestorOfBookmarked.py \
_IsLessThanNthGenerationAncestorOfDefaultPerson.py \
_IsLessThanNthGenerationDescendantOf.py \
_IsMale.py \
_IsMoreThanNthGenerationAncestorOf.py \
_IsMoreThanNthGenerationDescendantOf.py \
_IsParentOfFilterMatch.py \
_IsSiblingOfFilterMatch.py \
_IsSpouseOfFilterMatch.py \
_IsWitness.py \
_MatchesFilter.py \
_MultipleMarriages.py \
_NeverMarried.py \
_NoBirthdate.py \
_PeoplePrivate.py \
_PersonWithIncompleteEvent.py \
_ProbablyAlive.py \
_RelationshipPathBetween.py \
_Rule.py \
_RuleUtils.py \
_SearchName.py \
__init__.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules
@ -67,7 +15,7 @@ pkgpythondir = @pkgpythondir@/Filters/Rules
# Clean up all the byte-compiled files
MOSTLYCLEANFILES = *pyc *pyo
GRAMPS_PY_MODPATH = "../"
GRAMPS_PY_MODPATH = "../../"
pycheck:
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \

View File

@ -0,0 +1,18 @@
# This is the src/Filters/Rules/Media level Makefile for Gramps
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Media
pkgdata_PYTHON = \
__init__.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Media
pkgpythondir = @pkgpythondir@/Filters/Rules/Media
# 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,27 @@
#
# 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: __init__.py 6521 2006-05-03 01:02:54Z rshura $
"""
Package providing filter rules for GRAMPS.
"""
__author__ = "Don Allingham"

View File

@ -0,0 +1,74 @@
# This is the src/Filters/Rules/Person level Makefile for Gramps
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Person
pkgdata_PYTHON = \
_Disconnected.py \
_Everyone.py \
_FamilyWithIncompleteEvent.py \
_HasAttribute.py \
_HasBirth.py \
_HasCommonAncestorWith.py \
_HasCommonAncestorWithFilterMatch.py \
_HasCompleteRecord.py \
_HasDeath.py \
_HasEvent.py \
_HasFamilyAttribute.py \
_HasFamilyEvent.py \
_HasIdOf.py \
_HasNameOf.py \
_HasNote.py \
_HasNoteMatchingSubstringOf.py \
_HasRelationship.py \
_HasSourceOf.py \
_HasTextMatchingRegexpOf.py \
_HasTextMatchingSubstringOf.py \
_HasUnknownGender.py \
_HaveAltFamilies.py \
_HaveChildren.py \
_HavePhotos.py \
_IncompleteNames.py \
_IsAncestorOf.py \
_IsAncestorOfFilterMatch.py \
_IsBookmarked.py \
_IsChildOfFilterMatch.py \
_IsDefaultPerson.py \
_IsDescendantFamilyOf.py \
_IsDescendantOf.py \
_IsDescendantOfFilterMatch.py \
_IsFemale.py \
_IsLessThanNthGenerationAncestorOf.py \
_IsLessThanNthGenerationAncestorOfBookmarked.py \
_IsLessThanNthGenerationAncestorOfDefaultPerson.py \
_IsLessThanNthGenerationDescendantOf.py \
_IsMale.py \
_IsMoreThanNthGenerationAncestorOf.py \
_IsMoreThanNthGenerationDescendantOf.py \
_IsParentOfFilterMatch.py \
_IsSiblingOfFilterMatch.py \
_IsSpouseOfFilterMatch.py \
_IsWitness.py \
_MatchesFilter.py \
_MultipleMarriages.py \
_NeverMarried.py \
_NoBirthdate.py \
_PeoplePrivate.py \
_PersonWithIncompleteEvent.py \
_ProbablyAlive.py \
_RelationshipPathBetween.py \
_Rule.py \
_RuleUtils.py \
_SearchName.py \
__init__.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Person
pkgpythondir = @pkgpythondir@/Filters/Rules/Person
# Clean up all the byte-compiled files
MOSTLYCLEANFILES = *pyc *pyo
GRAMPS_PY_MODPATH = "../../../"
pycheck:
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
pychecker $(pkgdata_PYTHON));

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "Families with incomplete events"

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -33,8 +33,8 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
import DateHandler
from _Rule import Rule
from _RuleUtils import date_cmp
from Filters.Rules._Rule import Rule
from Filters.Rules._RuleUtils import date_cmp
#-------------------------------------------------------------------------
#

View File

@ -33,7 +33,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
from Utils import for_each_ancestor
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -33,8 +33,8 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
import DateHandler
from _Rule import Rule
from _RuleUtils import date_cmp
from Filters.Rules._Rule import Rule
from Filters.Rules._RuleUtils import date_cmp
#-------------------------------------------------------------------------
#

View File

@ -33,8 +33,8 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
import DateHandler
from _Rule import Rule
from _RuleUtils import date_cmp
from Filters.Rules._Rule import Rule
from Filters.Rules._RuleUtils import date_cmp
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -33,8 +33,8 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
import DateHandler
from _Rule import Rule
from _RuleUtils import date_cmp
from Filters.Rules._Rule import Rule
from Filters.Rules._RuleUtils import date_cmp
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "People having notes"

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "People having notes that contain a substring"

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -0,0 +1,56 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _HasTextMatchingSubstringOf import HasTextMatchingSubstringOf
#-------------------------------------------------------------------------
# "HasTextMatchingRegexOf"
#-------------------------------------------------------------------------
class HasTextMatchingRegexpOf(HasTextMatchingSubstringOf):
"""This is wrapping HasTextMatchingSubstringOf to enable the regex_match parameter"""
def __init__(self,list):
HasTextMatchingSubstringOf.__init__(self,list)
def prepare(self,db):
self.db = db
self.person_map = {}
self.event_map = {}
self.source_map = {}
self.repo_map = {}
self.family_map = {}
self.place_map = {}
self.media_map = {}
self.case_sensitive = False
self.regexp_match = True
self.cache_sources()

View File

@ -0,0 +1,197 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Utils import get_source_referents
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "HasTextMatchingSubstringOf"
#-------------------------------------------------------------------------
class HasTextMatchingSubstringOf(Rule):
"""Rule that checks for string matches in any textual information"""
labels = [ _('Substring:'),
_('Case sensitive:'),
_('Regular-Expression matching:')]
name = _('People with records containing <substring>')
description = _("Matches people whose records contain text "
"matching a substring")
category = _('General filters')
def prepare(self,db):
self.db = db
self.person_map = {}
self.event_map = {}
self.source_map = {}
self.repo_map = {}
self.family_map = {}
self.place_map = {}
self.media_map = {}
try:
if int(self.list[1]):
self.case_sensitive = True
else:
self.case_sensitive = False
except IndexError:
self.case_sensitive = False
try:
if int(self.list[2]):
self.regexp_match = True
else:
self.regexp_match = False
except IndexError:
self.regexp_match = False
self.cache_repos()
self.cache_sources()
def reset(self):
self.person_map = {}
self.event_map = {}
self.source_map = {}
self.repo_map = {}
self.family_map = {}
self.place_map = {}
self.media_map = {}
def apply(self,db,person):
if person.handle in self.person_map: # Cached by matching Source?
return self.person_map[person.handle]
if self.match_object(person): # first match the person itself
return True
for event_ref in person.get_event_ref_list()+[person.get_birth_ref(), person.get_death_ref()]:
if self.search_event(event_ref.ref): # match referenced events
return True
for family_handle in person.get_family_handle_list(): # match families
if self.search_family(family_handle):
return True
for media_ref in person.get_media_list(): # match Media object
if self.search_media(media_ref.get_reference_handle()):
return True
return False
def search_family(self,family_handle):
if not family_handle:
return False
# search inside the family and cache the result to not search a family twice
if not family_handle in self.family_map:
match = 0
family = self.db.get_family_from_handle(family_handle)
if self.match_object(family):
match = 1
else:
for event_ref in family.get_event_ref_list():
if self.search_event(event_ref.ref):
match = 1
break
for media_ref in family.get_media_list(): # match Media object
if self.search_media(media_ref.get_reference_handle()):
return True
self.family_map[family_handle] = match
return self.family_map[family_handle]
def search_event(self,event_handle):
if not event_handle:
return False
# search inside the event and cache the result (event sharing)
if not event_handle in self.event_map:
match = 0
event = self.db.get_event_from_handle(event_handle)
if self.match_object(event):
match = 1
elif event:
place_handle = event.get_place_handle()
if place_handle:
if self.search_place(place_handle):
match = 1
for media_ref in event.get_media_list(): # match Media object
if self.search_media(media_ref.get_reference_handle()):
return True
self.event_map[event_handle] = match
return self.event_map[event_handle]
def search_place(self,place_handle):
if not place_handle:
return False
# search inside the place and cache the result
if not place_handle in self.place_map:
place = self.db.get_place_from_handle(place_handle)
self.place_map[place_handle] = self.match_object(place)
return self.place_map[place_handle]
def search_media(self,media_handle):
if not media_handle:
return False
# search inside the place and cache the result
if not media_handle in self.media_map:
media = self.db.get_object_from_handle(media_handle)
self.media_map[media_handle] = self.match_object(media)
return self.media_map[media_handle]
def cache_repos(self):
# search all matching repositories
for repo_handle in self.db.get_repository_handles():
repo = self.db.get_repository_from_handle(repo_handle)
if( self.match_object(repo)):
self.repo_map[repo_handle] = 1
def cache_sources(self):
# search all sources and match all referents of a matching source
for source_handle in self.db.get_source_handles():
source = self.db.get_source_from_handle(source_handle)
match = self.match_object(source)
if not match:
for reporef in source.get_reporef_list():
if reporef.get_reference_handle() in self.repo_map:
match = 1
if match:
(person_list,family_list,event_list,
place_list,source_list,media_list
) = get_source_referents(source_handle,self.db)
for handle in person_list:
self.person_map[handle] = 1
for handle in family_list:
self.family_map[handle] = 1
for handle in event_list:
self.event_map[handle] = 1
for handle in place_list:
self.place_map[handle] = 1
for handle in media_list:
self.media_map[handle] = 1
def match_object(self,obj):
if not obj:
return False
if self.regexp_match:
return obj.matches_regexp(self.list[0],self.case_sensitive)
return obj.matches_string(self.list[0],self.case_sensitive)

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
from RelLib import Person
#-------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
from RelLib import ChildRefType
#-------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "People with children"

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "People who have images"

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
from _MatchesFilter import MatchesFilter
#-------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
from RelLib import Person
#-------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
from RelLib import Person
#-------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
from _MatchesFilter import MatchesFilter
#-------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
from _MatchesFilter import MatchesFilter
#-------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
from _MatchesFilter import MatchesFilter
#-------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "Witnesses"

View File

@ -33,7 +33,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
from Filters import SystemFilters, CustomFilters
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "People with multiple marriage records"

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "People with no marriage records"

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "People without a birth date"

View File

@ -32,17 +32,14 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._IsPrivate import IsPrivate
#-------------------------------------------------------------------------
# "People marked private"
#-------------------------------------------------------------------------
class PeoplePrivate(Rule):
class PeoplePrivate(IsPrivate):
"""People marked private"""
name = _('People marked private')
description = _("Matches people that are indicated as private")
category = _('General filters')
def apply(self,db,person):
return person.get_privacy()

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "People with incomplete events"

View File

@ -33,7 +33,7 @@ from gettext import gettext as _
#
#-------------------------------------------------------------------------
from Utils import probably_alive
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
# "People probably alive"

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
#-------------------------------------------------------------------------
#

View File

@ -32,7 +32,7 @@ from gettext import gettext as _
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
from Filters.Rules._Rule import Rule
import NameDisplay
#-------------------------------------------------------------------------

View File

@ -0,0 +1,148 @@
#
# 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$
"""
Package providing filter rules for GRAMPS.
"""
__author__ = "Don Allingham"
from _Disconnected import Disconnected
from _Everyone import Everyone
from _FamilyWithIncompleteEvent import FamilyWithIncompleteEvent
from _HasAttribute import HasAttribute
from _HasBirth import HasBirth
from _HasCommonAncestorWith import HasCommonAncestorWith
from _HasCommonAncestorWithFilterMatch import HasCommonAncestorWithFilterMatch
from _HasCompleteRecord import HasCompleteRecord
from _HasDeath import HasDeath
from _HasEvent import HasEvent
from _HasFamilyAttribute import HasFamilyAttribute
from _HasFamilyEvent import HasFamilyEvent
from _HasIdOf import HasIdOf
from _HasNameOf import HasNameOf
from _HasNote import HasNote
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasRelationship import HasRelationship
from _HasSourceOf import HasSourceOf
from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf
from _HasTextMatchingSubstringOf import HasTextMatchingSubstringOf
from _HasUnknownGender import HasUnknownGender
from _HaveAltFamilies import HaveAltFamilies
from _HaveChildren import HaveChildren
from _HavePhotos import HavePhotos
from _IncompleteNames import IncompleteNames
from _IsAncestorOf import IsAncestorOf
from _IsAncestorOfFilterMatch import IsAncestorOfFilterMatch
from _IsBookmarked import IsBookmarked
from _IsChildOfFilterMatch import IsChildOfFilterMatch
from _IsDefaultPerson import IsDefaultPerson
from _IsDescendantFamilyOf import IsDescendantFamilyOf
from _IsDescendantOf import IsDescendantOf
from _IsDescendantOfFilterMatch import IsDescendantOfFilterMatch
from _IsFemale import IsFemale
from _IsLessThanNthGenerationAncestorOf import \
IsLessThanNthGenerationAncestorOf
from _IsLessThanNthGenerationAncestorOfBookmarked import \
IsLessThanNthGenerationAncestorOfBookmarked
from _IsLessThanNthGenerationAncestorOfDefaultPerson import \
IsLessThanNthGenerationAncestorOfDefaultPerson
from _IsLessThanNthGenerationDescendantOf import \
IsLessThanNthGenerationDescendantOf
from _IsMale import IsMale
from _IsMoreThanNthGenerationAncestorOf import \
IsMoreThanNthGenerationAncestorOf
from _IsMoreThanNthGenerationDescendantOf import \
IsMoreThanNthGenerationDescendantOf
from _IsParentOfFilterMatch import IsParentOfFilterMatch
from _IsSiblingOfFilterMatch import IsSiblingOfFilterMatch
from _IsSpouseOfFilterMatch import IsSpouseOfFilterMatch
from _IsWitness import IsWitness
from _MatchesFilter import MatchesFilter
from _MultipleMarriages import MultipleMarriages
from _NeverMarried import NeverMarried
from _NoBirthdate import NoBirthdate
from _PeoplePrivate import PeoplePrivate
from _PersonWithIncompleteEvent import PersonWithIncompleteEvent
from _ProbablyAlive import ProbablyAlive
from _RelationshipPathBetween import RelationshipPathBetween
from Filters.Rules._Rule import Rule
from _SearchName import SearchName
#-------------------------------------------------------------------------
#
# This is used by Custom Filter Editor tool
#
#-------------------------------------------------------------------------
editor_rule_list = [
Everyone,
IsFemale,
HasUnknownGender,
IsMale,
IsDefaultPerson,
IsBookmarked,
HasIdOf,
HasNameOf,
HasRelationship,
HasDeath,
HasBirth,
HasCompleteRecord,
HasEvent,
HasFamilyEvent,
HasAttribute,
HasFamilyAttribute,
HasSourceOf,
HaveAltFamilies,
HavePhotos,
HaveChildren,
IncompleteNames,
NeverMarried,
MultipleMarriages,
NoBirthdate,
PersonWithIncompleteEvent,
FamilyWithIncompleteEvent,
ProbablyAlive,
PeoplePrivate,
IsWitness,
IsDescendantOf,
IsDescendantFamilyOf,
IsLessThanNthGenerationAncestorOfDefaultPerson,
IsDescendantOfFilterMatch,
IsLessThanNthGenerationDescendantOf,
IsMoreThanNthGenerationDescendantOf,
IsAncestorOf,
IsAncestorOfFilterMatch,
IsLessThanNthGenerationAncestorOf,
IsLessThanNthGenerationAncestorOfBookmarked,
IsMoreThanNthGenerationAncestorOf,
HasCommonAncestorWith,
HasCommonAncestorWithFilterMatch,
MatchesFilter,
IsChildOfFilterMatch,
IsParentOfFilterMatch,
IsSpouseOfFilterMatch,
IsSiblingOfFilterMatch,
RelationshipPathBetween,
HasTextMatchingSubstringOf,
HasNote,
HasNoteMatchingSubstringOf
]

View File

@ -0,0 +1,18 @@
# This is the src/Filters/Rules/Place level Makefile for Gramps
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Place
pkgdata_PYTHON = \
__init__.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Place
pkgpythondir = @pkgpythondir@/Filters/Rules/Place
# 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,27 @@
#
# 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: __init__.py 6521 2006-05-03 01:02:54Z rshura $
"""
Package providing filter rules for GRAMPS.
"""
__author__ = "Don Allingham"

View File

@ -0,0 +1,18 @@
# This is the src/Filters/Rules/Media level Makefile for Gramps
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Repository
pkgdata_PYTHON = \
__init__.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Repository
pkgpythondir = @pkgpythondir@/Filters/Rules/Repository
# 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,27 @@
#
# 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: __init__.py 6521 2006-05-03 01:02:54Z rshura $
"""
Package providing filter rules for GRAMPS.
"""
__author__ = "Don Allingham"

View File

@ -0,0 +1,18 @@
# This is the src/Filters/Rules/Source level Makefile for Gramps
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Source
pkgdata_PYTHON = \
__init__.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Source
pkgpythondir = @pkgpythondir@/Filters/Rules/Source
# 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,27 @@
#
# 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: __init__.py 6521 2006-05-03 01:02:54Z rshura $
"""
Package providing filter rules for GRAMPS.
"""
__author__ = "Don Allingham"

View File

@ -0,0 +1,53 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
#-------------------------------------------------------------------------
#
# Everyone
#
#-------------------------------------------------------------------------
class Everything(Rule):
"""Matches Everyone"""
name = _('Every object')
category = _('General filters')
description = _('Matches every object in the database')
def is_empty(self):
return True
def apply(self,db,obj):
return True

View File

@ -42,15 +42,5 @@ class HasTextMatchingRegexpOf(HasTextMatchingSubstringOf):
def __init__(self,list):
HasTextMatchingSubstringOf.__init__(self,list)
def prepare(self,db):
self.db = db
self.person_map = {}
self.event_map = {}
self.source_map = {}
self.repo_map = {}
self.family_map = {}
self.place_map = {}
self.media_map = {}
self.case_sensitive = False
self.regexp_match = True
self.cache_sources()
# FIXME: This needs to be written for an arbitrary object
# if possible

View File

@ -49,149 +49,5 @@ class HasTextMatchingSubstringOf(Rule):
"matching a substring")
category = _('General filters')
def prepare(self,db):
self.db = db
self.person_map = {}
self.event_map = {}
self.source_map = {}
self.repo_map = {}
self.family_map = {}
self.place_map = {}
self.media_map = {}
try:
if int(self.list[1]):
self.case_sensitive = True
else:
self.case_sensitive = False
except IndexError:
self.case_sensitive = False
try:
if int(self.list[2]):
self.regexp_match = True
else:
self.regexp_match = False
except IndexError:
self.regexp_match = False
self.cache_repos()
self.cache_sources()
def reset(self):
self.person_map = {}
self.event_map = {}
self.source_map = {}
self.repo_map = {}
self.family_map = {}
self.place_map = {}
self.media_map = {}
def apply(self,db,person):
if person.handle in self.person_map: # Cached by matching Source?
return self.person_map[person.handle]
if self.match_object(person): # first match the person itself
return True
for event_ref in person.get_event_ref_list()+[person.get_birth_ref(), person.get_death_ref()]:
if self.search_event(event_ref.ref): # match referenced events
return True
for family_handle in person.get_family_handle_list(): # match families
if self.search_family(family_handle):
return True
for media_ref in person.get_media_list(): # match Media object
if self.search_media(media_ref.get_reference_handle()):
return True
return False
def search_family(self,family_handle):
if not family_handle:
return False
# search inside the family and cache the result to not search a family twice
if not family_handle in self.family_map:
match = 0
family = self.db.get_family_from_handle(family_handle)
if self.match_object(family):
match = 1
else:
for event_ref in family.get_event_ref_list():
if self.search_event(event_ref.ref):
match = 1
break
for media_ref in family.get_media_list(): # match Media object
if self.search_media(media_ref.get_reference_handle()):
return True
self.family_map[family_handle] = match
return self.family_map[family_handle]
def search_event(self,event_handle):
if not event_handle:
return False
# search inside the event and cache the result (event sharing)
if not event_handle in self.event_map:
match = 0
event = self.db.get_event_from_handle(event_handle)
if self.match_object(event):
match = 1
elif event:
place_handle = event.get_place_handle()
if place_handle:
if self.search_place(place_handle):
match = 1
for media_ref in event.get_media_list(): # match Media object
if self.search_media(media_ref.get_reference_handle()):
return True
self.event_map[event_handle] = match
return self.event_map[event_handle]
def search_place(self,place_handle):
if not place_handle:
return False
# search inside the place and cache the result
if not place_handle in self.place_map:
place = self.db.get_place_from_handle(place_handle)
self.place_map[place_handle] = self.match_object(place)
return self.place_map[place_handle]
def search_media(self,media_handle):
if not media_handle:
return False
# search inside the place and cache the result
if not media_handle in self.media_map:
media = self.db.get_object_from_handle(media_handle)
self.media_map[media_handle] = self.match_object(media)
return self.media_map[media_handle]
def cache_repos(self):
# search all matching repositories
for repo_handle in self.db.get_repository_handles():
repo = self.db.get_repository_from_handle(repo_handle)
if( self.match_object(repo)):
self.repo_map[repo_handle] = 1
def cache_sources(self):
# search all sources and match all referents of a matching source
for source_handle in self.db.get_source_handles():
source = self.db.get_source_from_handle(source_handle)
match = self.match_object(source)
if not match:
for reporef in source.get_reporef_list():
if reporef.get_reference_handle() in self.repo_map:
match = 1
if match:
(person_list,family_list,event_list,
place_list,source_list,media_list
) = get_source_referents(source_handle,self.db)
for handle in person_list:
self.person_map[handle] = 1
for handle in family_list:
self.family_map[handle] = 1
for handle in event_list:
self.event_map[handle] = 1
for handle in place_list:
self.place_map[handle] = 1
for handle in media_list:
self.media_map[handle] = 1
def match_object(self,obj):
if not obj:
return False
if self.regexp_match:
return obj.matches_regexp(self.list[0],self.case_sensitive)
return obj.matches_string(self.list[0],self.case_sensitive)
# FIXME: This needs to be written for an arbitrary object
# if possible

View File

@ -0,0 +1,48 @@
#
# 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$
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from _Rule import Rule
#-------------------------------------------------------------------------
# "People marked private"
#-------------------------------------------------------------------------
class IsPrivate(Rule):
"""Objects marked private"""
name = _('Objects marked private')
description = _("Matches objects that are indicated as private")
category = _('General filters')
def apply(self,db,obj):
return obj.get_privacy()

View File

@ -26,121 +26,15 @@ Package providing filter rules for GRAMPS.
__author__ = "Don Allingham"
from _Disconnected import Disconnected
from _Everyone import Everyone
from _FamilyWithIncompleteEvent import FamilyWithIncompleteEvent
from _HasAttribute import HasAttribute
from _HasBirth import HasBirth
from _HasCommonAncestorWith import HasCommonAncestorWith
from _HasCommonAncestorWithFilterMatch import HasCommonAncestorWithFilterMatch
from _HasCompleteRecord import HasCompleteRecord
from _HasDeath import HasDeath
from _HasEvent import HasEvent
from _HasFamilyAttribute import HasFamilyAttribute
from _HasFamilyEvent import HasFamilyEvent
from _HasIdOf import HasIdOf
from _HasNameOf import HasNameOf
from _HasNote import HasNote
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _HasRelationship import HasRelationship
from _HasSourceOf import HasSourceOf
from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf
from _Everything import Everything
from _IsPrivate import IsPrivate
from _HasTextMatchingSubstringOf import HasTextMatchingSubstringOf
from _HasUnknownGender import HasUnknownGender
from _HaveAltFamilies import HaveAltFamilies
from _HaveChildren import HaveChildren
from _HavePhotos import HavePhotos
from _IncompleteNames import IncompleteNames
from _IsAncestorOf import IsAncestorOf
from _IsAncestorOfFilterMatch import IsAncestorOfFilterMatch
from _IsBookmarked import IsBookmarked
from _IsChildOfFilterMatch import IsChildOfFilterMatch
from _IsDefaultPerson import IsDefaultPerson
from _IsDescendantFamilyOf import IsDescendantFamilyOf
from _IsDescendantOf import IsDescendantOf
from _IsDescendantOfFilterMatch import IsDescendantOfFilterMatch
from _IsFemale import IsFemale
from _IsLessThanNthGenerationAncestorOf import IsLessThanNthGenerationAncestorOf
from _IsLessThanNthGenerationAncestorOfBookmarked import \
IsLessThanNthGenerationAncestorOfBookmarked
from _IsLessThanNthGenerationAncestorOfDefaultPerson import \
IsLessThanNthGenerationAncestorOfDefaultPerson
from _IsLessThanNthGenerationDescendantOf import \
IsLessThanNthGenerationDescendantOf
from _IsMale import IsMale
from _IsMoreThanNthGenerationAncestorOf import IsMoreThanNthGenerationAncestorOf
from _IsMoreThanNthGenerationDescendantOf import \
IsMoreThanNthGenerationDescendantOf
from _IsParentOfFilterMatch import IsParentOfFilterMatch
from _IsSiblingOfFilterMatch import IsSiblingOfFilterMatch
from _IsSpouseOfFilterMatch import IsSpouseOfFilterMatch
from _IsWitness import IsWitness
from _MatchesFilter import MatchesFilter
from _MultipleMarriages import MultipleMarriages
from _NeverMarried import NeverMarried
from _NoBirthdate import NoBirthdate
from _PeoplePrivate import PeoplePrivate
from _PersonWithIncompleteEvent import PersonWithIncompleteEvent
from _ProbablyAlive import ProbablyAlive
from _RelationshipPathBetween import RelationshipPathBetween
from _Rule import Rule
from _SearchName import SearchName
from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf
#-------------------------------------------------------------------------
#
# This is used by Custom Filter Editor tool
#
#-------------------------------------------------------------------------
editor_rule_list = [
Everyone,
IsFemale,
HasUnknownGender,
IsMale,
IsDefaultPerson,
IsBookmarked,
HasIdOf,
HasNameOf,
HasRelationship,
HasDeath,
HasBirth,
HasCompleteRecord,
HasEvent,
HasFamilyEvent,
HasAttribute,
HasFamilyAttribute,
HasSourceOf,
HaveAltFamilies,
HavePhotos,
HaveChildren,
IncompleteNames,
NeverMarried,
MultipleMarriages,
NoBirthdate,
PersonWithIncompleteEvent,
FamilyWithIncompleteEvent,
ProbablyAlive,
PeoplePrivate,
IsWitness,
IsDescendantOf,
IsDescendantFamilyOf,
IsLessThanNthGenerationAncestorOfDefaultPerson,
IsDescendantOfFilterMatch,
IsLessThanNthGenerationDescendantOf,
IsMoreThanNthGenerationDescendantOf,
IsAncestorOf,
IsAncestorOfFilterMatch,
IsLessThanNthGenerationAncestorOf,
IsLessThanNthGenerationAncestorOfBookmarked,
IsMoreThanNthGenerationAncestorOf,
HasCommonAncestorWith,
HasCommonAncestorWithFilterMatch,
MatchesFilter,
IsChildOfFilterMatch,
IsParentOfFilterMatch,
IsSpouseOfFilterMatch,
IsSiblingOfFilterMatch,
RelationshipPathBetween,
HasTextMatchingSubstringOf,
HasNote,
HasNoteMatchingSubstringOf
]
import Person
import Family
import Event
import Source
import Place
import Media
import Repository

View File

@ -88,16 +88,15 @@ class FilterList:
f.write('<object type="%s">\n' % namespace)
filter_list = self.filter_namespaces[namespace]
for the_filter in filter_list:
f.write(' <filter name="%s"' % self.fix(the_filter.get_name()))
f.write(' <filter name="%s"' %self.fix(the_filter.get_name()))
f.write(' function="%s"' % the_filter.get_logical_op())
comment = the_filter.get_comment()
if comment:
f.write(' comment="%s"' % self.fix(comment))
f.write('>\n')
for rule in the_filter.get_rules():
rule_class_name = rule.__class__.__name__
rule_save_name = "Filters.Rules.%s" % rule_class_name
f.write(' <rule class="%s">\n' % rule_save_name)
f.write(' <rule class="%s">\n'
% rule.__class__.__name__)
for v in rule.values():
f.write(' <arg value="%s"/>\n' % self.fix(v))
f.write(' </rule>\n')

View File

@ -50,7 +50,7 @@ class FilterParser(handler.ContentHandler):
self.r = None
self.a = []
self.cname = None
self.namespace = "person"
self.namespace = "Person"
def setDocumentLocator(self,locator):
self.locator = locator
@ -84,13 +84,15 @@ class FilterParser(handler.ContentHandler):
try:
# First try to use fully qualified name
exec 'self.r = %s' % save_name
except (ImportError,NameError,AttributeError):
# Now try to use name from Rules
except (ImportError, NameError, AttributeError ):
# Now try to use name from Rules.Namespace
mc_match = save_name.split('.')
try:
exec 'self.r = Rules.%s' % mc_match[-1]
except (ImportError,NameError):
print "ERROR: Filter rule '%s' in filter '%s' not found!"\
exec 'self.r = Rules.%s.%s' % (
self.namespace,mc_match[-1])
except (ImportError, NameError ):
print "ERROR: Filter rule '%s' in "\
"filter '%s' not found!"\
% (save_name,self.f.get_name())
self.r = None
return
@ -124,56 +126,58 @@ class FilterParser(handler.ContentHandler):
# This dict is mapping from old names to new names, so that the existing
# custom_filters.xml will continue working
old_names_2_class = {
"Everyone" : Rules.Everyone,
"Is default person" : Rules.IsDefaultPerson,
"Is bookmarked person" : Rules.IsBookmarked,
"Has the Id" : Rules.HasIdOf,
"Has a name" : Rules.HasNameOf,
"Has the relationships" : Rules.HasRelationship,
"Has the death" : Rules.HasDeath,
"Has the birth" : Rules.HasBirth,
"Is a descendant of" : Rules.IsDescendantOf,
"Is a descendant family member of" : Rules.IsDescendantFamilyOf,
"Is a descendant of filter match": Rules.IsDescendantOfFilterMatch,
"Everyone" : Rules.Person.Everyone,
"Is default person" : Rules.Person.IsDefaultPerson,
"Is bookmarked person" : Rules.Person.IsBookmarked,
"Has the Id" : Rules.Person.HasIdOf,
"Has a name" : Rules.Person.HasNameOf,
"Has the relationships" : Rules.Person.HasRelationship,
"Has the death" : Rules.Person.HasDeath,
"Has the birth" : Rules.Person.HasBirth,
"Is a descendant of" : Rules.Person.IsDescendantOf,
"Is a descendant family member of" : Rules.Person.IsDescendantFamilyOf,
"Is a descendant of filter match": Rules.Person.IsDescendantOfFilterMatch,
"Is a descendant of person not more than N generations away":
Rules.IsLessThanNthGenerationDescendantOf,
Rules.Person.IsLessThanNthGenerationDescendantOf,
"Is a descendant of person at least N generations away":
Rules.IsMoreThanNthGenerationDescendantOf,
Rules.Person.IsMoreThanNthGenerationDescendantOf,
"Is an descendant of person at least N generations away" :
Rules.IsMoreThanNthGenerationDescendantOf,
"Is a child of filter match" : Rules.IsChildOfFilterMatch,
"Is an ancestor of" : Rules.IsAncestorOf,
"Is an ancestor of filter match": Rules.IsAncestorOfFilterMatch,
Rules.Person.IsMoreThanNthGenerationDescendantOf,
"Is a child of filter match" : Rules.Person.IsChildOfFilterMatch,
"Is an ancestor of" : Rules.Person.IsAncestorOf,
"Is an ancestor of filter match": Rules.Person.IsAncestorOfFilterMatch,
"Is an ancestor of person not more than N generations away" :
Rules.IsLessThanNthGenerationAncestorOf,
Rules.Person.IsLessThanNthGenerationAncestorOf,
"Is an ancestor of person at least N generations away":
Rules.IsMoreThanNthGenerationAncestorOf,
"Is a parent of filter match" : Rules.IsParentOfFilterMatch,
"Has a common ancestor with" : Rules.HasCommonAncestorWith,
"Has a common ancestor with filter match" :Rules.HasCommonAncestorWithFilterMatch,
"Is a female" : Rules.IsFemale,
"Is a male" : Rules.IsMale,
"Has complete record" : Rules.HasCompleteRecord,
"Has the personal event" : Rules.HasEvent,
"Has the family event" : Rules.HasFamilyEvent,
"Has the personal attribute" : Rules.HasAttribute,
"Has the family attribute" : Rules.HasFamilyAttribute,
"Has source of" : Rules.HasSourceOf,
"Matches the filter named" : Rules.HasSourceOf,
"Is spouse of filter match" : Rules.IsSpouseOfFilterMatch,
"Is a sibling of filter match" : Rules.IsSiblingOfFilterMatch,
"Relationship path between two people" : Rules.RelationshipPathBetween,
"People who were adopted" : Rules.HaveAltFamilies,
"People who have images" : Rules.HavePhotos,
"People with children" : Rules.HaveChildren,
"People with incomplete names" : Rules.IncompleteNames,
"People with no marriage records" : Rules.NeverMarried,
"People with multiple marriage records": Rules.MultipleMarriages,
"People without a birth date" : Rules.NoBirthdate,
"People with incomplete events" : Rules.PersonWithIncompleteEvent,
"Families with incomplete events" :Rules.FamilyWithIncompleteEvent,
"People probably alive" : Rules.ProbablyAlive,
"People marked private" : Rules.PeoplePrivate,
"Witnesses" : Rules.IsWitness,
"Has text matching substring of": Rules.HasTextMatchingSubstringOf,
Rules.Person.IsMoreThanNthGenerationAncestorOf,
"Is a parent of filter match" : Rules.Person.IsParentOfFilterMatch,
"Has a common ancestor with" : Rules.Person.HasCommonAncestorWith,
"Has a common ancestor with filter match" :
Rules.Person.HasCommonAncestorWithFilterMatch,
"Is a female" : Rules.Person.IsFemale,
"Is a male" : Rules.Person.IsMale,
"Has complete record" : Rules.Person.HasCompleteRecord,
"Has the personal event" : Rules.Person.HasEvent,
"Has the family event" : Rules.Person.HasFamilyEvent,
"Has the personal attribute" : Rules.Person.HasAttribute,
"Has the family attribute" : Rules.Person.HasFamilyAttribute,
"Has source of" : Rules.Person.HasSourceOf,
"Matches the filter named" : Rules.Person.HasSourceOf,
"Is spouse of filter match" : Rules.Person.IsSpouseOfFilterMatch,
"Is a sibling of filter match" : Rules.Person.IsSiblingOfFilterMatch,
"Relationship path between two people" :
Rules.Person.RelationshipPathBetween,
"People who were adopted" : Rules.Person.HaveAltFamilies,
"People who have images" : Rules.Person.HavePhotos,
"People with children" : Rules.Person.HaveChildren,
"People with incomplete names" : Rules.Person.IncompleteNames,
"People with no marriage records" : Rules.Person.NeverMarried,
"People with multiple marriage records": Rules.Person.MultipleMarriages,
"People without a birth date" : Rules.Person.NoBirthdate,
"People with incomplete events" : Rules.Person.PersonWithIncompleteEvent,
"Families with incomplete events" :Rules.Person.FamilyWithIncompleteEvent,
"People probably alive" : Rules.Person.ProbablyAlive,
"People marked private" : Rules.Person.PeoplePrivate,
"Witnesses" : Rules.Person.IsWitness,
"Has text matching substring of": Rules.Person.HasTextMatchingSubstringOf,
}

View File

@ -372,25 +372,25 @@ class GedcomWriterOptionBox:
all = GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(Rules.Everyone([]))
all.add_rule(Rules.Person.Everyone([]))
if self.person:
des = GenericFilter()
des.set_name(_("Descendants of %s") %
NameDisplay.displayer.display(self.person))
des.add_rule(Rules.IsDescendantOf(
des.add_rule(Rules.Person.IsDescendantOf(
[self.person.get_gramps_id(),1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s")
% NameDisplay.displayer.display(self.person))
ans.add_rule(Rules.IsAncestorOf(
ans.add_rule(Rules.Person.IsAncestorOf(
[self.person.get_gramps_id(),1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") %
NameDisplay.displayer.display(self.person))
com.add_rule(Rules.HasCommonAncestorWith(
com.add_rule(Rules.Person.HasCommonAncestorWith(
[self.person.get_gramps_id()]))
self.filter_menu = build_filter_menu([all,des,ans,com])

View File

@ -157,29 +157,29 @@ class PersonFilterFrame(FilterFrameBase):
filter_label.set_alignment(xalign=0,yalign=0.5)
default_filters = [
Rules.Everyone,
Rules.IsFemale,
Rules.IsMale,
Rules.HasUnknownGender,
Rules.Disconnected,
Rules.SearchName,
Rules.HaveAltFamilies,
Rules.HavePhotos,
Rules.IncompleteNames,
Rules.HaveChildren,
Rules.NeverMarried,
Rules.MultipleMarriages,
Rules.NoBirthdate,
Rules.PersonWithIncompleteEvent,
Rules.FamilyWithIncompleteEvent,
Rules.ProbablyAlive,
Rules.PeoplePrivate,
Rules.IsWitness,
Rules.HasTextMatchingSubstringOf,
Rules.HasTextMatchingRegexpOf,
Rules.HasNote,
Rules.HasNoteMatchingSubstringOf,
Rules.IsFemale,
Rules.Person.Everyone,
Rules.Person.IsFemale,
Rules.Person.IsMale,
Rules.Person.HasUnknownGender,
Rules.Person.Disconnected,
Rules.Person.SearchName,
Rules.Person.HaveAltFamilies,
Rules.Person.HavePhotos,
Rules.Person.IncompleteNames,
Rules.Person.HaveChildren,
Rules.Person.NeverMarried,
Rules.Person.MultipleMarriages,
Rules.Person.NoBirthdate,
Rules.Person.PersonWithIncompleteEvent,
Rules.Person.FamilyWithIncompleteEvent,
Rules.Person.ProbablyAlive,
Rules.Person.PeoplePrivate,
Rules.Person.IsWitness,
Rules.Person.HasTextMatchingSubstringOf,
Rules.Person.HasTextMatchingRegexpOf,
Rules.Person.HasNote,
Rules.Person.HasNoteMatchingSubstringOf,
Rules.Person.IsFemale,
]
self._filter_list = gtk.ListStore(object,str)
@ -365,19 +365,19 @@ class PersonFilterFrame(FilterFrameBase):
filter = GenericFilter()
if self._id_check.get_active():
filter.add_rule(Rules.HasIdOf([self._id_edit.get_text()]))
filter.add_rule(Rules.Person.HasIdOf([self._id_edit.get_text()]))
if self._name_check.get_active():
filter.add_rule(Rules.SearchName([self._name_edit.get_text()]))
filter.add_rule(Rules.Person.SearchName([self._name_edit.get_text()]))
if self._gender_check.get_active():
gender = self._gender_list.get_value(self._gender_combo.get_active_iter(),1)
if gender == RelLib.Person.MALE:
filter.add_rule(Rules.IsMale([]))
filter.add_rule(Rules.Person.IsMale([]))
elif gender == RelLib.Person.FEMALE:
filter.add_rule(Rules.IsFemale([]))
filter.add_rule(Rules.Person.IsFemale([]))
elif gender == RelLib.Person.UNKNOWN:
filter.add_rule(Rules.HasUnknownGender([]))
filter.add_rule(Rules.Person.HasUnknownGender([]))
else:
log.warn("Received unknown gender from filter widget")
@ -389,7 +389,7 @@ class PersonFilterFrame(FilterFrameBase):
date = "after " + self._b_edit.get_text()
else:
log.warn("neither before or after is selected, this should not happen")
filter.add_rule(Rules.HasBirth([date,'','']))
filter.add_rule(Rules.Person.HasBirth([date,'','']))
if self._death_check.get_active():
date = ""
@ -399,7 +399,7 @@ class PersonFilterFrame(FilterFrameBase):
date = "after " + self._d_edit.get_text()
else:
log.warn("neither before or after is selected, this should not happen")
filter.add_rule(Rules.HasDeath([date,'','']))
filter.add_rule(Rules.Person.HasDeath([date,'','']))
if self._filter_check.get_active():

View File

@ -527,10 +527,10 @@ class ListView(BookMarkView):
Builds the default filters and add them to the filter menu.
"""
default_filters = [
[Rules.Everyone, []],
[Rules.Everything, []],
[Rules.HasTextMatchingSubstringOf, ['',0,0]],
[Rules.HasTextMatchingRegexpOf, ['',0,1]],
[Rules.PeoplePrivate, []],
[Rules.IsPrivate, []],
]
self.generic_filter_widget.setup_filter( default_filters)

View File

@ -912,7 +912,7 @@ class BareReportDialog:
self.options.handler.set_filter_number(active)
except:
print "Error setting filter. Proceeding with 'Everyone'"
self.filter = Rules.Everyone([])
self.filter = Rules.Person.Everyone([])
else:
self.filter = None

View File

@ -1,4 +1,3 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 Donald N. Allingham
@ -528,32 +527,32 @@ class FilterWidget(Widget):
if filter in ["everyone", "all filters"]:
f = GenericFilter()
f.set_name(_("Entire Database"))
f.add_rule(Rules.Everyone([]))
f.add_rule(Rules.Person.Everyone([]))
retval.append(f)
if filter in ["descendants", "all filters"]:
f = GenericFilter()
f.set_name(_("Descendants of %s") % name)
f.add_rule(Rules.IsDescendantOf([gramps_id,1]))
f.add_rule(Rules.Person.IsDescendantOf([gramps_id,1]))
retval.append(f)
if filter in ["descendant families", "all filters"]:
f = GenericFilter()
f.set_name(_("Descendant Families of %s") % name)
f.add_rule(Rules.IsDescendantFamilyOf([gramps_id]))
f.add_rule(Rules.Person.IsDescendantFamilyOf([gramps_id]))
retval.append(f)
if filter in ["ancestors", "all filters"]:
f = GenericFilter()
f.set_name(_("Ancestors of %s") % name)
f.add_rule(Rules.IsAncestorOf([gramps_id,1]))
f.add_rule(Rules.Person.IsAncestorOf([gramps_id,1]))
retval.append(f)
if filter in ["common ancestors", "all filters"]:
f = GenericFilter()
f.set_name(_("People with common ancestor with %s") % name)
f.add_rule(Rules.HasCommonAncestorWith([gramps_id]))
f.add_rule(Rules.Person.HasCommonAncestorWith([gramps_id]))
retval.append(f)
if filter in ["calendar attribute", "all filters"]:
f = ParamFilter()
f.set_name(_("People with a Calendar attribute"))
f.add_rule(Rules.HasTextMatchingSubstringOf(['Calendar',0,0]))
f.add_rule(Rules.Person.HasTextMatchingSubstringOf(['Calendar',0,0]))
retval.append(f)
return retval

View File

@ -154,7 +154,7 @@ class EventComparison(Tool.Tool,ManagedWindow.ManagedWindow):
self.all = GenericFilter()
self.all.set_name(_("Entire Database"))
self.all.add_rule(Rules.Everyone([]))
self.all.add_rule(Rules.Person.Everyone([]))
self.filter_menu = build_filter_menu([self.all])
filter_num = self.options.handler.get_filter_number()

View File

@ -86,25 +86,25 @@ class CalendarWriterOptionBox:
all = GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(Rules.Everyone([]))
all.add_rule(Rules.Person.Everyone([]))
if self.person:
des = GenericFilter()
des.set_name(_("Descendants of %s") %
self.person.get_primary_name().get_name())
des.add_rule(Rules.IsDescendantOf(
des.add_rule(Rules.Person.IsDescendantOf(
[self.person.get_gramps_id(),1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s") %
self.person.get_primary_name().get_name())
ans.add_rule(Rules.IsAncestorOf(
ans.add_rule(Rules.Person.IsAncestorOf(
[self.person.get_gramps_id(),1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") %
self.person.get_primary_name().get_name())
com.add_rule(Rules.HasCommonAncestorWith(
com.add_rule(Rules.Person.HasCommonAncestorWith(
[self.person.get_gramps_id()]))
self.filter_menu = build_filter_menu(

View File

@ -84,25 +84,25 @@ class CardWriterOptionBox:
all = GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(Rules.Everyone([]))
all.add_rule(Rules.Person.Everyone([]))
if self.person:
des = GenericFilter()
des.set_name(_("Descendants of %s") %
self.person.get_primary_name().get_name())
des.add_rule(Rules.IsDescendantOf(
des.add_rule(Rules.Person.IsDescendantOf(
[self.person.get_gramps_id(),1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s") %
self.person.get_primary_name().get_name())
ans.add_rule(Rules.IsAncestorOf(
ans.add_rule(Rules.Person.IsAncestorOf(
[self.person.get_gramps_id(),1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") %
self.person.get_primary_name().get_name())
com.add_rule(Rules.HasCommonAncestorWith(
com.add_rule(Rules.Person.HasCommonAncestorWith(
[self.person.get_gramps_id()]))
self.filter_menu = build_filter_menu(

View File

@ -620,7 +620,7 @@ class EditRule:
self.page = []
self.class2page = {}
the_map = {}
for class_obj in Rules.editor_rule_list:
for class_obj in Rules.Person.editor_rule_list:
arglist = class_obj.labels
vallist = []
tlist = []

View File

@ -656,19 +656,19 @@ class GraphVizOptions(ReportOptions.ReportOptions):
all = GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(Rules.Everyone([]))
all.add_rule(Rules.Person.Everyone([]))
des = GenericFilter()
des.set_name(_("Descendants of %s") % name)
des.add_rule(Rule.IsDescendantOf([gramps_id,1]))
des.add_rule(Rules.Person.IsDescendantOf([gramps_id,1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s") % name)
ans.add_rule(Rule.IsAncestorOf([gramps_id,1]))
ans.add_rule(Rules.Person.IsAncestorOf([gramps_id,1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") % name)
com.add_rule(Rules.HasCommonAncestorWith([gramps_id]))
com.add_rule(Rules.Person.HasCommonAncestorWith([gramps_id]))
return [all,des,ans,com]

View File

@ -522,23 +522,23 @@ class IndivCompleteOptions(ReportOptions.ReportOptions):
filt_id = GenericFilter()
filt_id.set_name(name)
filt_id.add_rule(Rules.HasIdOf([gramps_id]))
filt_id.add_rule(Rules.Person.HasIdOf([gramps_id]))
all = GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(Rules.Everyone([]))
all.add_rule(Rules.Person.Everyone([]))
des = GenericFilter()
des.set_name(_("Descendants of %s") % name)
des.add_rule(Rules.IsDescendantOf([gramps_id,1]))
des.add_rule(Rules.Person.IsDescendantOf([gramps_id,1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s") % name)
ans.add_rule(Rules.IsAncestorOf([gramps_id,1]))
ans.add_rule(Rules.Person.IsAncestorOf([gramps_id,1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") % name)
com.add_rule(Rules.HasCommonAncestorWith([gramps_id]))
com.add_rule(Rules.Person.HasCommonAncestorWith([gramps_id]))
return [filt_id,all,des,ans,com]

View File

@ -2405,23 +2405,23 @@ class WebReportOptions(ReportOptions.ReportOptions):
all = GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(Rules.Everyone([]))
all.add_rule(Rules.Person.Everyone([]))
des = GenericFilter()
des.set_name(_("Descendants of %s") % name)
des.add_rule(Rules.IsDescendantOf([gramps_id,1]))
des.add_rule(Rules.Person.IsDescendantOf([gramps_id,1]))
df = GenericFilter()
df.set_name(_("Descendant Families of %s") % name)
df.add_rule(Rules.IsDescendantFamilyOf([gramps_id]))
df.add_rule(Rules.Person.IsDescendantFamilyOf([gramps_id]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s") % name)
ans.add_rule(Rules.IsAncestorOf([gramps_id,1]))
ans.add_rule(Rules.Person.IsAncestorOf([gramps_id,1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") % name)
com.add_rule(Rules.HasCommonAncestorWith([gramps_id]))
com.add_rule(Rules.Person.HasCommonAncestorWith([gramps_id]))
return [all,des,df,ans,com]

View File

@ -843,19 +843,19 @@ class StatisticsChartOptions(ReportOptions.ReportOptions):
all = GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(Rules.Everyone([]))
all.add_rule(Rules.Person.Everyone([]))
des = GenericFilter()
des.set_name(_("Descendants of %s") % name)
des.add_rule(Rules.IsDescendantOf([gramps_id, 1]))
des.add_rule(Rules.Person.IsDescendantOf([gramps_id, 1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s") % name)
ans.add_rule(Rules.IsAncestorOf([gramps_id, 1]))
ans.add_rule(Rules.Person.IsAncestorOf([gramps_id, 1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") % name)
com.add_rule(Rules.HasCommonAncestorWith([gramps_id]))
com.add_rule(Rules.Person.HasCommonAncestorWith([gramps_id]))
return [all, des, ans, com]

View File

@ -411,19 +411,19 @@ class TimeLineOptions(ReportOptions.ReportOptions):
all = GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(Rules.Everyone([]))
all.add_rule(Rules.Person.Everyone([]))
des = GenericFilter()
des.set_name(_("Descendants of %s") % name)
des.add_rule(Rules.IsDescendantOf([gramps_id,1]))
des.add_rule(Rules.Person.IsDescendantOf([gramps_id,1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s") % name)
ans.add_rule(Rules.IsAncestorOf([gramps_id,1]))
ans.add_rule(Rules.Person.IsAncestorOf([gramps_id,1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") % name)
com.add_rule(Rules.HasCommonAncestorWith([gramps_id]))
com.add_rule(Rules.Person.HasCommonAncestorWith([gramps_id]))
return [all,des,ans,com]

View File

@ -88,25 +88,25 @@ class FtreeWriterOptionBox:
all = GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(Rules.Everyone([]))
all.add_rule(Rules.Person.Everyone([]))
if self.person:
des = GenericFilter()
des.set_name(_("Descendants of %s") %
self.person.get_primary_name().get_name())
des.add_rule(Rules.IsDescendantOf(
des.add_rule(Rules.Person.IsDescendantOf(
[self.person.get_gramps_id(),1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s")
% self.person.get_primary_name().get_name())
ans.add_rule(Rules.IsAncestorOf(
ans.add_rule(Rules.Person.IsAncestorOf(
[self.person.get_gramps_id(),1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") %
self.person.get_primary_name().get_name())
com.add_rule(Rules.HasCommonAncestorWith(
com.add_rule(Rules.Person.HasCommonAncestorWith(
[self.person.get_gramps_id()]))
self.filter_menu = build_filter_menu([all,des,ans,com])

View File

@ -90,25 +90,25 @@ class GeneWebWriterOptionBox:
all = GenericFilter()
all.set_name(_("Entire Database"))
all.add_rule(Rules.Everyone([]))
all.add_rule(Rules.Person.Everyone([]))
if self.person:
des = GenericFilter()
des.set_name(_("Descendants of %s") %
self.person.get_primary_name().get_name())
des.add_rule(Rules.IsDescendantOf(
des.add_rule(Rules.Person.IsDescendantOf(
[self.person.get_gramps_id(),1]))
ans = GenericFilter()
ans.set_name(_("Ancestors of %s") %
self.person.get_primary_name().get_name())
ans.add_rule(Rules.IsAncestorOf(
ans.add_rule(Rules.Person.IsAncestorOf(
[self.person.get_gramps_id(),1]))
com = GenericFilter()
com.set_name(_("People with common ancestor with %s") %
self.person.get_primary_name().get_name())
com.add_rule(Rules.HasCommonAncestorWith(
com.add_rule(Rules.Person.HasCommonAncestorWith(
[self.person.get_gramps_id()]))
self.filter_menu = build_filter_menu([all,des,ans,com])