2006-05-12 Don Allingham <don@gramps-project.org>
* src/DataViews/_PersonView.py: set up new filter fields * src/Filters/Rules/Person/_RegExpIdOf.py: added * src/Filters/Rules/Person/__init__.py: added new files * src/Filters/Rules/Person/_HasNoteMatchingSubstringOf.py * src/Filters/Rules/Person/_HasBirth.py: use loose_data_cmp * src/Filters/Rules/Person/_SearchName.py: search all fields * src/Filters/Rules/Person/_HasDeath.py: use loose_data_cmp * src/Filters/Rules/Person/_RegExpName.py: added * src/Filters/Rules/Person/_MatchIdOf.py: added * src/Filters/Rules/Person/_HasNoteRegexp.py: added * src/Filters/Rules/Person/Makefile.am: added new files * src/Filters/Rules/_RuleUtils.py: added loose_date_cmp 2006-04-26 Martin Hawlisch <Martin.Hawlisch@gmx.de> svn: r6634
This commit is contained in:
parent
bf1a9212ff
commit
fdd56563e7
16
ChangeLog
16
ChangeLog
@ -1,4 +1,18 @@
|
||||
2006-04-26 Martin wlisch <Martin.Hawlisch@gmx.de>
|
||||
2006-05-12 Don Allingham <don@gramps-project.org>
|
||||
* src/DataViews/_PersonView.py: set up new filter fields
|
||||
* src/Filters/Rules/Person/_RegExpIdOf.py: added
|
||||
* src/Filters/Rules/Person/__init__.py: added new files
|
||||
* src/Filters/Rules/Person/_HasNoteMatchingSubstringOf.py
|
||||
* src/Filters/Rules/Person/_HasBirth.py: use loose_data_cmp
|
||||
* src/Filters/Rules/Person/_SearchName.py: search all fields
|
||||
* src/Filters/Rules/Person/_HasDeath.py: use loose_data_cmp
|
||||
* src/Filters/Rules/Person/_RegExpName.py: added
|
||||
* src/Filters/Rules/Person/_MatchIdOf.py: added
|
||||
* src/Filters/Rules/Person/_HasNoteRegexp.py: added
|
||||
* src/Filters/Rules/Person/Makefile.am: added new files
|
||||
* src/Filters/Rules/_RuleUtils.py: added loose_date_cmp
|
||||
|
||||
2006-04-26 Martin Hawlisch <Martin.Hawlisch@gmx.de>
|
||||
* data/gramps.schemas.in: Swap colors for ToDo and complete. Using
|
||||
green is more obvious for complete records.
|
||||
|
||||
|
@ -216,7 +216,7 @@ class PersonView(PageView.PersonNavView):
|
||||
return hpaned
|
||||
|
||||
def build_filter_sidebar(self):
|
||||
table = gtk.Table(3,10)
|
||||
table = gtk.Table(3,11)
|
||||
table.set_border_width(6)
|
||||
table.set_row_spacings(6)
|
||||
|
||||
@ -225,9 +225,16 @@ class PersonView(PageView.PersonNavView):
|
||||
self.filter_birth = gtk.Entry()
|
||||
self.filter_death = gtk.Entry()
|
||||
self.filter_event = gtk.Entry()
|
||||
self.filter_event.set_sensitive(False)
|
||||
|
||||
self.filter_source = gtk.Entry()
|
||||
self.filter_source.set_sensitive(False)
|
||||
|
||||
self.filter_note = gtk.Entry()
|
||||
self.filter_gender = gtk.Entry()
|
||||
self.filter_gender = gtk.combo_box_new_text()
|
||||
for i in [ _('any'), _('male'), _('female'), _('unknown') ]:
|
||||
self.filter_gender.append_text(i)
|
||||
|
||||
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
|
||||
|
||||
self.apply_btn = gtk.Button(stock=gtk.STOCK_FIND)
|
||||
@ -251,39 +258,45 @@ class PersonView(PageView.PersonNavView):
|
||||
table.attach(self.filter_id, 2, 3, 2, 3,
|
||||
xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(GrampsWidgets.BasicLabel(_('Birth')),
|
||||
table.attach(GrampsWidgets.BasicLabel(_('Gender')),
|
||||
1, 2, 3, 4, xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(self.filter_birth, 2, 3, 3, 4,
|
||||
table.attach(self.filter_gender, 2, 3, 3, 4,
|
||||
xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(GrampsWidgets.BasicLabel(_('Death')),
|
||||
table.attach(GrampsWidgets.BasicLabel(_('Birth date')),
|
||||
1, 2, 4, 5, xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(self.filter_death, 2, 3, 4, 5,
|
||||
table.attach(self.filter_birth, 2, 3, 4, 5,
|
||||
xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(GrampsWidgets.BasicLabel(_('Death date')),
|
||||
1, 2, 5, 6, xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(self.filter_death, 2, 3, 5, 6,
|
||||
xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(GrampsWidgets.BasicLabel(_('Event')),
|
||||
1, 2, 5, 6, xoptions=gtk.FILL, yoptions=0)
|
||||
1, 2, 6, 7, xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(self.filter_event, 2, 3, 5, 6,
|
||||
table.attach(self.filter_event, 2, 3, 6, 7,
|
||||
xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(GrampsWidgets.BasicLabel(_('Source')),
|
||||
1, 2, 6, 7, xoptions=gtk.FILL, yoptions=0)
|
||||
1, 2, 7, 8, xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(self.filter_source, 2, 3, 6, 7,
|
||||
table.attach(self.filter_source, 2, 3, 7, 8,
|
||||
xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(GrampsWidgets.BasicLabel(_('Note')),
|
||||
1, 2, 7, 8, xoptions=gtk.FILL, yoptions=0)
|
||||
1, 2, 8, 9, xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(self.filter_note, 2, 3, 7, 8,
|
||||
table.attach(self.filter_note, 2, 3, 8, 9,
|
||||
xoptions=gtk.FILL, yoptions=0)
|
||||
|
||||
table.attach(self.filter_regex, 2, 3, 8, 9, xoptions=gtk.FILL,
|
||||
table.attach(self.filter_regex, 2, 3, 9, 10, xoptions=gtk.FILL,
|
||||
yoptions=0)
|
||||
table.attach(self.apply_btn, 2, 3, 9, 10, xoptions=0,
|
||||
table.attach(self.apply_btn, 2, 3, 10, 11, xoptions=0,
|
||||
yoptions=0)
|
||||
|
||||
return table
|
||||
@ -296,19 +309,47 @@ class PersonView(PageView.PersonNavView):
|
||||
event = self.filter_event.get_text().strip()
|
||||
source = self.filter_source.get_text().strip()
|
||||
note = self.filter_note.get_text().strip()
|
||||
gender = self.filter_gender.get_text().strip()
|
||||
gender = self.filter_gender.get_active()
|
||||
regex = self.filter_regex.get_active()
|
||||
|
||||
if not name and not gid and not death and not event and \
|
||||
not source and not note and not gender:
|
||||
if not name and not gid and not birth and not death \
|
||||
and not event and not source and not note and not gender > 0:
|
||||
self.generic_filter = None
|
||||
else:
|
||||
self.generic_filter = GenericFilter()
|
||||
if name:
|
||||
rule = SearchName([name])
|
||||
if regex:
|
||||
rule = RegExpName([name])
|
||||
else:
|
||||
rule = SearchName([name])
|
||||
self.generic_filter.add_rule(rule)
|
||||
self.build_tree()
|
||||
print self.generic_filter
|
||||
if gid:
|
||||
if regex:
|
||||
rule = RegExpIdOf([gid])
|
||||
else:
|
||||
rule = MatchIdOf([gid])
|
||||
self.generic_filter.add_rule(rule)
|
||||
if gender > 0:
|
||||
if gender == 1:
|
||||
self.generic_filter.add_rule(IsMale([]))
|
||||
elif gender == 2:
|
||||
self.generic_filter.add_rule(IsFemale([]))
|
||||
else:
|
||||
self.generic_filter.add_rule(HasUnknownGender([]))
|
||||
if birth:
|
||||
rule = HasBirth([birth,'',''])
|
||||
self.generic_filter.add_rule(rule)
|
||||
if death:
|
||||
rule = HasDeath([death,'',''])
|
||||
self.generic_filter.add_rule(rule)
|
||||
if note:
|
||||
if regex:
|
||||
rule = HasNoteRegexp([note])
|
||||
else:
|
||||
rule = HasNoteMatchingSubstringOf([note])
|
||||
self.generic_filter.add_rule(rule)
|
||||
|
||||
self.build_tree()
|
||||
|
||||
def drag_begin(self, widget, *data):
|
||||
widget.drag_source_set_icon_stock(self.get_stock())
|
||||
|
@ -57,6 +57,10 @@ pkgdata_PYTHON = \
|
||||
_ProbablyAlive.py \
|
||||
_RelationshipPathBetween.py \
|
||||
_SearchName.py \
|
||||
_RegExpIdOf.py \
|
||||
_MatchIdOf.py \
|
||||
_HasNoteRegexp.py \
|
||||
_RegExpName.py \
|
||||
__init__.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Person
|
||||
|
@ -34,7 +34,7 @@ from gettext import gettext as _
|
||||
#-------------------------------------------------------------------------
|
||||
import DateHandler
|
||||
from Filters.Rules._Rule import Rule
|
||||
from Filters.Rules._RuleUtils import date_cmp
|
||||
from Filters.Rules._RuleUtils import loose_date_cmp
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -66,7 +66,7 @@ class HasBirth(Rule):
|
||||
and ed.find(self.list[2].upper())==-1:
|
||||
return False
|
||||
if self.date:
|
||||
if date_cmp(self.date,event.get_date_object()) == 0:
|
||||
if loose_date_cmp(self.date,event.get_date_object()) == 0:
|
||||
return False
|
||||
if self.list[1]:
|
||||
pl_id = event.get_place_handle()
|
||||
|
@ -34,7 +34,7 @@ from gettext import gettext as _
|
||||
#-------------------------------------------------------------------------
|
||||
import DateHandler
|
||||
from Filters.Rules._Rule import Rule
|
||||
from Filters.Rules._RuleUtils import date_cmp
|
||||
from Filters.Rules._RuleUtils import loose_date_cmp
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -66,7 +66,7 @@ class HasDeath(Rule):
|
||||
and ed.find(self.list[2].upper())==-1:
|
||||
return False
|
||||
if self.date:
|
||||
if date_cmp(self.date,event.get_date_object()) == 0:
|
||||
if loose_date_cmp(self.date,event.get_date_object()) == 0:
|
||||
return False
|
||||
if self.list[1]:
|
||||
pl_id = event.get_place_handle()
|
||||
|
@ -54,32 +54,36 @@ class HasEvent(Rule):
|
||||
|
||||
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_handle in person.get_event_list():
|
||||
if not event_handle:
|
||||
for event_ref in person.get_event_ref_list():
|
||||
if not event_ref:
|
||||
continue
|
||||
event = db.get_event_from_handle(event_handle)
|
||||
val = 1
|
||||
if self.list[0] and event.get_name() != self.list[0]:
|
||||
val = 0
|
||||
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 = 0
|
||||
val = False
|
||||
if self.date:
|
||||
if date_cmp(self.date,event.get_date_object()):
|
||||
val = 0
|
||||
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 = 0
|
||||
if val == 1:
|
||||
val = False
|
||||
if val:
|
||||
return True
|
||||
return False
|
||||
|
@ -41,7 +41,7 @@ class HasNoteMatchingSubstringOf(Rule):
|
||||
"""People having notes containing <subtring>"""
|
||||
|
||||
labels = [ _('Substring:')]
|
||||
name = _('People having notes containing <subtring>')
|
||||
name = _('People having notes containing <substring>')
|
||||
description = _("Matches people whose notes contain text matching a substring")
|
||||
category = _('General filters')
|
||||
|
||||
|
58
src/Filters/Rules/Person/_HasNoteRegexp.py
Normal file
58
src/Filters/Rules/Person/_HasNoteRegexp.py
Normal file
@ -0,0 +1,58 @@
|
||||
#
|
||||
# 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: _HasNoteMatchingSubstringOf.py 6529 2006-05-03 06:29:07Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._Rule import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "People having notes that contain a substring"
|
||||
#-------------------------------------------------------------------------
|
||||
class HasNoteRegexp(Rule):
|
||||
"""People having notes containing <subtring>"""
|
||||
|
||||
labels = [ _('Regular expression:')]
|
||||
name = _('People having notes containing <regular expression>')
|
||||
description = _("Matches people whose notes contain text matching a regular expression")
|
||||
category = _('General filters')
|
||||
|
||||
def __init__(self, list):
|
||||
Rule.__init__(self, list)
|
||||
|
||||
try:
|
||||
self.match = re.compile(list[0],re.I|re.U|re.L)
|
||||
except:
|
||||
self.match = re.compile('')
|
||||
|
||||
def apply(self,db,person):
|
||||
n = person.get_note()
|
||||
return self.match.match(n) != None
|
51
src/Filters/Rules/Person/_MatchIdOf.py
Normal file
51
src/Filters/Rules/Person/_MatchIdOf.py
Normal 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: _HasIdOf.py 6529 2006-05-03 06:29:07Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._Rule import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasIdOf
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MatchIdOf(Rule):
|
||||
"""Rule that checks for a person with a specific GRAMPS ID"""
|
||||
|
||||
labels = [ _('ID:') ]
|
||||
name = _('People with <Id>')
|
||||
description = _("Matches people with a specified GRAMPS ID")
|
||||
category = _('General filters')
|
||||
|
||||
def apply(self,db,person):
|
||||
return person.gramps_id.find(self.list[0]) !=-1
|
60
src/Filters/Rules/Person/_RegExpIdOf.py
Normal file
60
src/Filters/Rules/Person/_RegExpIdOf.py
Normal file
@ -0,0 +1,60 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2002-2006 Donald N. Allingham
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id: _HasIdOf.py 6529 2006-05-03 06:29:07Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
import re
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._Rule import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasIdOf
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class RegExpIdOf(Rule):
|
||||
"""Rule that checks for a person with a specific GRAMPS ID"""
|
||||
|
||||
labels = [ _('ID:') ]
|
||||
name = _('People with <Id>')
|
||||
description = _("Matches people with a GRAMPS ID that contains the regular expression")
|
||||
category = _('General filters')
|
||||
|
||||
def __init__(self, list):
|
||||
Rule.__init__(self, list)
|
||||
|
||||
try:
|
||||
self.match = re.compile(list[0],re.I|re.U|re.L)
|
||||
except:
|
||||
self.match = re.compile('')
|
||||
|
||||
def apply(self,db,person):
|
||||
return self.match.match(person.gramps_id) != None
|
66
src/Filters/Rules/Person/_RegExpName.py
Normal file
66
src/Filters/Rules/Person/_RegExpName.py
Normal file
@ -0,0 +1,66 @@
|
||||
#
|
||||
# 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: _SearchName.py 6529 2006-05-03 06:29:07Z rshura $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._Rule import Rule
|
||||
import re
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasNameOf
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class RegExpName(Rule):
|
||||
"""Rule that checks for full or partial name matches"""
|
||||
|
||||
labels = [_('Expresssion:')]
|
||||
name = _('People matching the <regex_name>')
|
||||
description = _("Matches people's names with a specified regular expression")
|
||||
category = _('General filters')
|
||||
|
||||
def __init__(self, list):
|
||||
Rule.__init__(self, list)
|
||||
|
||||
try:
|
||||
self.match = re.compile(list[0],re.I|re.U|re.L)
|
||||
except:
|
||||
self.match = re.compile('')
|
||||
|
||||
def apply(self,db,person):
|
||||
for name in [person.get_primary_name()] + person.get_alternate_names():
|
||||
for field in [name.first_name, name.surname, name.suffix, name.title,
|
||||
name.prefix, name.patronymic]:
|
||||
if self.match.match(field):
|
||||
return True
|
||||
else:
|
||||
return False
|
@ -33,7 +33,6 @@ from gettext import gettext as _
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._Rule import Rule
|
||||
import NameDisplay
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -49,6 +48,13 @@ class SearchName(Rule):
|
||||
category = _('General filters')
|
||||
|
||||
def apply(self,db,person):
|
||||
self.f = self.list[0]
|
||||
n = NameDisplay.displayer.display(person)
|
||||
return self.f and n.upper().find(self.f.upper()) != -1
|
||||
|
||||
src = self.list[0].upper()
|
||||
|
||||
for name in [person.get_primary_name()] + person.get_alternate_names():
|
||||
for field in [name.first_name, name.surname, name.suffix, name.title,
|
||||
name.prefix, name.patronymic]:
|
||||
if src and field.upper().find(src) != -1:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
@ -42,6 +42,7 @@ from _HasIdOf import HasIdOf
|
||||
from _HasNameOf import HasNameOf
|
||||
from _HasNote import HasNote
|
||||
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
|
||||
from _HasNoteRegexp import HasNoteRegexp
|
||||
from _HasRelationship import HasRelationship
|
||||
from _HasSourceOf import HasSourceOf
|
||||
from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf
|
||||
@ -87,6 +88,9 @@ from _ProbablyAlive import ProbablyAlive
|
||||
from _RelationshipPathBetween import RelationshipPathBetween
|
||||
from Filters.Rules._Rule import Rule
|
||||
from _SearchName import SearchName
|
||||
from _RegExpName import RegExpName
|
||||
from _MatchIdOf import MatchIdOf
|
||||
from _RegExpIdOf import RegExpIdOf
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
import RelLib
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Useful functions used by some rules
|
||||
@ -37,3 +39,21 @@ def date_cmp(rule,value):
|
||||
return cmp_rule < cmp_value
|
||||
else:
|
||||
return cmp_rule == cmp_value
|
||||
|
||||
def loose_date_cmp(rule,value):
|
||||
sd = rule.get_start_date()
|
||||
s = rule.get_modifier()
|
||||
od = value.get_start_date()
|
||||
cmp_rule = (sd[2],sd[1],sd[0])
|
||||
cmp_value = (od[2],od[1],od[0])
|
||||
|
||||
if s == RelLib.Date.MOD_BEFORE:
|
||||
return cmp_rule > cmp_value
|
||||
elif s == RelLib.Date.MOD_AFTER:
|
||||
return cmp_rule < cmp_value
|
||||
elif cmp_rule[0] and not cmp_rule[1] and not cmp_rule[2]:
|
||||
return cmp_rule[0] == cmp_value[0]
|
||||
elif cmp_rule[0] and cmp_rule[1] and not cmp_rule[2]:
|
||||
return cmp_rule[0:2] == cmp_value[0:2]
|
||||
else:
|
||||
return cmp_rule == cmp_value
|
||||
|
Loading…
Reference in New Issue
Block a user