* src/Filters/Rules/Person/_IsWitness.py: Rewrite with new API.
debugging output; (_name2typeclass): Add name->type mapping. svn: r7123
This commit is contained in:
parent
d265fadc1f
commit
47d6700f60
@ -1,4 +1,5 @@
|
|||||||
2006-08-04 Alex Roitman <shura@gramps-project.org>
|
2006-08-04 Alex Roitman <shura@gramps-project.org>
|
||||||
|
* src/Filters/Rules/Person/_IsWitness.py: Rewrite with new API.
|
||||||
* src/FilterEditor/_FilterEditor.py (__init__): Remove unneeded
|
* src/FilterEditor/_FilterEditor.py (__init__): Remove unneeded
|
||||||
argument, namespace is enough to get the filter class via factory;
|
argument, namespace is enough to get the filter class via factory;
|
||||||
(add_new_filter): Use factory; (get_all_handles): Get handles for
|
(add_new_filter): Use factory; (get_all_handles): Get handles for
|
||||||
@ -12,7 +13,9 @@
|
|||||||
* src/Filters/_FamilySidebarFilter.py (GenericFamilyFilter): Use
|
* src/Filters/_FamilySidebarFilter.py (GenericFamilyFilter): Use
|
||||||
factory.
|
factory.
|
||||||
* src/FilterEditor/_EditRule.py (MyID.name_from_gramps_id): Remove
|
* src/FilterEditor/_EditRule.py (MyID.name_from_gramps_id): Remove
|
||||||
debugginb output.
|
debugging output;
|
||||||
|
(_name2typeclass): Add name->type mapping.
|
||||||
|
|
||||||
* src/DataViews/_MediaView.py (row_change): Work around older pygtk.
|
* src/DataViews/_MediaView.py (row_change): Work around older pygtk.
|
||||||
* src/Filters/Rules/Family/Makefile.am (pkgdata_PYTHON): Ship new
|
* src/Filters/Rules/Family/Makefile.am (pkgdata_PYTHON): Ship new
|
||||||
files.
|
files.
|
||||||
|
@ -80,6 +80,7 @@ def by_rule_name(f,s):
|
|||||||
_name2typeclass = {
|
_name2typeclass = {
|
||||||
_('Personal event:') : RelLib.EventType,
|
_('Personal event:') : RelLib.EventType,
|
||||||
_('Family event:') : RelLib.EventType,
|
_('Family event:') : RelLib.EventType,
|
||||||
|
_('Event type:') : RelLib.EventType,
|
||||||
_('Personal attribute:') : RelLib.AttributeType,
|
_('Personal attribute:') : RelLib.AttributeType,
|
||||||
_('Family attribute:') : RelLib.AttributeType,
|
_('Family attribute:') : RelLib.AttributeType,
|
||||||
_('Relationship type:') : RelLib.FamilyRelType,
|
_('Relationship type:') : RelLib.FamilyRelType,
|
||||||
|
@ -33,6 +33,7 @@ from gettext import gettext as _
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
from Filters.Rules._Rule import Rule
|
from Filters.Rules._Rule import Rule
|
||||||
|
from RelLib import EventRoleType, EventType
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
# "Witnesses"
|
# "Witnesses"
|
||||||
@ -40,45 +41,23 @@ from Filters.Rules._Rule import Rule
|
|||||||
class IsWitness(Rule):
|
class IsWitness(Rule):
|
||||||
"""Witnesses"""
|
"""Witnesses"""
|
||||||
|
|
||||||
labels = [_('Personal event:'), _('Family event:')]
|
labels = [_('Event type:')]
|
||||||
name = _('Witnesses')
|
name = _('Witnesses')
|
||||||
description = _("Matches people who are witnesses in any event")
|
description = _("Matches people who are witnesses in any event")
|
||||||
category = _('Event filters')
|
category = _('Event filters')
|
||||||
|
|
||||||
def prepare(self,db):
|
|
||||||
self.db = db
|
|
||||||
self.map = []
|
|
||||||
self.build_witness_list()
|
|
||||||
|
|
||||||
def reset(self):
|
|
||||||
self.map = []
|
|
||||||
|
|
||||||
def apply(self,db,person):
|
def apply(self,db,person):
|
||||||
return person.handle in self.map
|
for event_ref in person.event_ref_list:
|
||||||
|
if event_ref.role == EventRoleType.WITNESS:
|
||||||
def build_witness_list(self):
|
# This is the witness.
|
||||||
for person_handle in self.db.get_person_handles():
|
# If event type was given, then check it.
|
||||||
p = self.db.get_person_from_handle(person_handle)
|
if self.list[0]:
|
||||||
self.get_witness_of_events(self.list[0],
|
event = db.get_event_from_handle(event_ref.ref)
|
||||||
p.get_event_ref_list()+
|
specified_type = EventType()
|
||||||
[p.get_birth_ref(),
|
specified_type.set_from_xml_str(self.list[0])
|
||||||
p.get_death_ref()]
|
if event.type == specified_type:
|
||||||
)
|
return True
|
||||||
|
else:
|
||||||
for family_handle in self.db.get_family_handles():
|
# event type was not specified, we're returning a match
|
||||||
f = self.db.get_family_from_handle(family_handle)
|
return True
|
||||||
self.get_witness_of_events(self.list[1],f.get_event_ref_list())
|
return False
|
||||||
|
|
||||||
def get_witness_of_events(self, event_type, event_list):
|
|
||||||
if not event_list:
|
|
||||||
return
|
|
||||||
for event_ref in event_list:
|
|
||||||
if event_ref:
|
|
||||||
event = self.db.get_event_from_handle(event_ref.ref)
|
|
||||||
if event_type and not event.get_name() == event_type:
|
|
||||||
continue
|
|
||||||
wlist = event.get_witness_list()
|
|
||||||
if wlist:
|
|
||||||
for w in wlist:
|
|
||||||
if w.get_type() == 1:
|
|
||||||
self.map.append(w.get_value())
|
|
||||||
|
Loading…
Reference in New Issue
Block a user