svn: r7021
This commit is contained in:
Don Allingham 2006-07-12 22:42:55 +00:00
parent ad5130dbf6
commit a89718f726
9 changed files with 217 additions and 51 deletions

View File

@ -3,7 +3,15 @@
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Family pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Family
pkgdata_PYTHON = \ pkgdata_PYTHON = \
__init__.py _AllFamilies.py\
_FamilyPrivate.py\
_HasEvent.py\
_HasIdOf.py\
_HasNoteMatchingSubstringOf.py\
_HasNoteRegexp.py\
_HasRelType.py\
__init__.py\
_RegExpIdOf.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Family pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Family
pkgpythondir = @pkgpythondir@/Filters/Rules/Family pkgpythondir = @pkgpythondir@/Filters/Rules/Family

View File

@ -0,0 +1,44 @@
#
# 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: _FamilyPrivate.py 6529 2006-05-03 06:29:07Z rshura $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._IsPrivate import IsPrivate
#-------------------------------------------------------------------------
# "Family marked private"
#-------------------------------------------------------------------------
class FamilyPrivate(IsPrivate):
"""Family marked private"""
name = _('Families marked private')
description = _("Matches families that are indicated as private")

View File

@ -0,0 +1,51 @@
#
# 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: _HasEvent.py 6635 2006-05-13 03:53:06Z dallingham $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
from Filters.Rules._HasEventBase import HasEventBase
#-------------------------------------------------------------------------
#
# HasEvent
#
#-------------------------------------------------------------------------
class HasEvent(HasEventBase):
"""Rule that checks for a person with a particular value"""
labels = [ _('Family event:'),
_('Date:'),
_('Place:'),
_('Description:') ]
name = _('Families with the <event>')
description = _("Matches families with an event of a particular value")

View File

@ -32,6 +32,8 @@ from _HasIdOf import HasIdOf
from _RegExpIdOf import RegExpIdOf from _RegExpIdOf import RegExpIdOf
from _HasNoteRegexp import HasNoteRegexp from _HasNoteRegexp import HasNoteRegexp
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
from _FamilyPrivate import FamilyPrivate
from _HasEvent import HasEvent
editor_rule_list = [ editor_rule_list = [
AllFamilies, AllFamilies,
@ -40,4 +42,6 @@ editor_rule_list = [
RegExpIdOf, RegExpIdOf,
HasNoteRegexp, HasNoteRegexp,
HasNoteMatchingSubstringOf, HasNoteMatchingSubstringOf,
FamilyPrivate,
HasEvent,
] ]

View File

@ -5,13 +5,18 @@ SUBDIRS = Person Family Event Place Source Media Repository
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules
pkgdata_PYTHON = \ pkgdata_PYTHON = \
_Everything.py \ _Everything.py\
_HasTextMatchingRegexpOf.py \ _HasEventBase.py\
_HasTextMatchingSubstringOf.py \ _HasGrampsId.py\
_IsPrivate.py \ _HasNoteRegexBase.py\
_Rule.py \ _HasNoteSubstrBase.py\
_RuleUtils.py \ _HasTextMatchingRegexpOf.py\
__init__.py _HasTextMatchingSubstringOf.py\
__init__.py\
_IsPrivate.py\
_RegExpIdBase.py\
_Rule.py\
_RuleUtils.py
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules pkgpyexecdir = @pkgpyexecdir@/Filters/Rules
pkgpythondir = @pkgpythondir@/Filters/Rules pkgpythondir = @pkgpythondir@/Filters/Rules

View File

@ -32,16 +32,14 @@ from gettext import gettext as _
# GRAMPS modules # GRAMPS modules
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
import DateHandler from Filters.Rules._HasEventBase import HasEventBase
from Filters.Rules._Rule import Rule
from Filters.Rules._RuleUtils import date_cmp
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
# HasEvent # HasEvent
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
class HasEvent(Rule): class HasEvent(HasEventBase):
"""Rule that checks for a person with a particular value""" """Rule that checks for a person with a particular value"""
labels = [ _('Personal event:'), labels = [ _('Personal event:'),
@ -50,40 +48,4 @@ class HasEvent(Rule):
_('Description:') ] _('Description:') ]
name = _('People with the personal <event>') name = _('People with the personal <event>')
description = _("Matches people with a personal event of a particular value") description = _("Matches people with a personal event of a particular value")
category = _('Event filters')
def prepare(self,db):
self.date = None
if self.list[0]:
self.etype = self.list[0]
else:
self.etype = None
try:
if self.list[1]:
self.date = DateHandler.parser.parse(self.list[1])
except: pass
def apply(self,db,person):
for event_ref in person.get_event_ref_list():
if not event_ref:
continue
event = db.get_event_from_handle(event_ref.ref)
val = True
if self.etype and event.get_type() != self.etype:
val = False
if self.list[3] and event.get_description().upper().find(
self.list[3].upper())==-1:
val = False
if self.date:
if date_cmp(self.date,event.get_date_object()):
val = False
if self.list[2]:
pl_id = event.get_place_handle()
if pl_id:
pl = db.get_place_from_handle(pl_id)
pn = pl.get_title()
if pn.upper().find(self.list[2].upper()) == -1:
val = False
if val:
return True
return False

View File

@ -0,0 +1,89 @@
#
# 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: _HasEvent.py 6635 2006-05-13 03:53:06Z dallingham $
#-------------------------------------------------------------------------
#
# Standard Python modules
#
#-------------------------------------------------------------------------
from gettext import gettext as _
#-------------------------------------------------------------------------
#
# GRAMPS modules
#
#-------------------------------------------------------------------------
import DateHandler
from Filters.Rules._Rule import Rule
from Filters.Rules._RuleUtils import date_cmp
#-------------------------------------------------------------------------
#
# HasEvent
#
#-------------------------------------------------------------------------
class HasEventBase(Rule):
"""Rule that checks for a person with a particular value"""
labels = [ _('Event:'),
_('Date:'),
_('Place:'),
_('Description:') ]
name = _('Objects with the <event>')
description = _("Matches objects with an event of a particular value")
category = _('Event filters')
def prepare(self,db):
self.date = None
if self.list[0]:
self.etype = self.list[0]
else:
self.etype = None
try:
if self.list[1]:
self.date = DateHandler.parser.parse(self.list[1])
except: pass
def apply(self,db,person):
for event_ref in person.get_event_ref_list():
if not event_ref:
continue
event = db.get_event_from_handle(event_ref.ref)
val = True
if self.etype and event.get_type() != self.etype:
val = False
if self.list[3] and event.get_description().upper().find(
self.list[3].upper())==-1:
val = False
if self.date:
if date_cmp(self.date,event.get_date_object()):
val = False
if self.list[2]:
pl_id = event.get_place_handle()
if pl_id:
pl = db.get_place_from_handle(pl_id)
pn = pl.get_title()
if pn.upper().find(self.list[2].upper()) == -1:
val = False
if val:
return True
return False

View File

@ -46,3 +46,6 @@ class HasGrampsId(Rule):
name = _('Object with <Id>') name = _('Object with <Id>')
description = _("Matches objects with a specified GRAMPS ID") description = _("Matches objects with a specified GRAMPS ID")
category = _('General filters') category = _('General filters')
def apply(self,db,obj):
return obj.gramps_id.find(self.list[0]) !=-1

View File

@ -26,8 +26,8 @@ import GrampsWidgets
import RelLib import RelLib
from _SidebarFilter import SidebarFilter from _SidebarFilter import SidebarFilter
import Filters.Rules
from Filters import GenericFamilyFilter, build_filter_model, Rules from Filters import GenericFamilyFilter, build_filter_model, Rules
from Filters.Rules.Family import *
class FamilySidebarFilter(SidebarFilter): class FamilySidebarFilter(SidebarFilter):
@ -61,7 +61,7 @@ class FamilySidebarFilter(SidebarFilter):
all = GenericFamilyFilter() all = GenericFamilyFilter()
all.set_name(_("None")) all.set_name(_("None"))
all.add_rule(Rules.Person.Everyone([])) all.add_rule(Rules.Family.AllFamilies([]))
self.generic = gtk.ComboBox() self.generic = gtk.ComboBox()
cell = gtk.CellRendererText() cell = gtk.CellRendererText()
@ -103,7 +103,7 @@ class FamilySidebarFilter(SidebarFilter):
if regex: if regex:
rule = RegExpIdOf([gid]) rule = RegExpIdOf([gid])
else: else:
rule = MatchIdOf([gid]) rule = HasIdOf([gid])
generic_filter.add_rule(rule) generic_filter.add_rule(rule)
etype = self.filter_event.get_type() etype = self.filter_event.get_type()