* src/plugins/BookReport.py (BookList.save): Write encoding.

* src/plugins/FilterEditor.py (MyBoolean): Add class.
(FilterEditor.edit_rule): Implement Inclusive option.
* src/GenericFilter.py: Add categories and descriptions. Implement
Inclusive option.


svn: r2093
This commit is contained in:
Alex Roitman 2003-09-05 04:38:43 +00:00
parent 336b296b85
commit 1c46081a4c
4 changed files with 156 additions and 13 deletions

View File

@ -1,3 +1,10 @@
2003-09-04 Alex Roitman <shura@alex.neuro.umn.edu>
* src/plugins/BookReport.py (BookList.save): Write encoding.
* src/plugins/FilterEditor.py (MyBoolean): Add class.
(FilterEditor.edit_rule): Implement Inclusive option.
* src/GenericFilter.py: Add categories and descriptions. Implement
Inclusive option.
2003-09-04 Don Allingham <dallingham@users.sourceforge.net>
* src/RelLib.py: backout yesterday's change

View File

@ -189,7 +189,7 @@ class IsDescendantOf(Rule):
"""Rule that checks for a person that is a descendant
of a specified person"""
labels = [ _('ID:') ]
labels = [ _('ID:'), _('Inclusive:') ]
def __init__(self,list):
Rule.__init__(self,list)
@ -207,11 +207,15 @@ class IsDescendantOf(Rule):
def apply(self,db,p):
self.orig = p
if int(self.list[1]):
first = 0
else:
first = 1
if not self.init:
self.init = 1
root = db.getPerson(self.list[0])
self.init_list(root,1)
self.init_list(root,first)
return self.map.has_key(p.getId())
def init_list(self,p,first):
@ -231,7 +235,7 @@ class IsDescendantOfFilterMatch(IsDescendantOf):
"""Rule that checks for a person that is a descendant
of someone matched by a filter"""
labels = [ _('Filter name:') ]
labels = [ _('Filter name:'), _('Inclusive:') ]
def __init__(self,list):
IsDescendantOf.__init__(self,list)
@ -247,13 +251,17 @@ class IsDescendantOfFilterMatch(IsDescendantOf):
def apply(self,db,p):
self.orig = p
if int(self.list[1]):
first = 0
else:
first = 1
if not self.init:
self.init = 1
filter = MatchesFilter(self.list)
for person in db.getPersonMap ().values ():
if filter.apply (db, person):
self.init_list (person, 1)
self.init_list (person, first)
return self.map.has_key(p.getId())
#-------------------------------------------------------------------------
@ -363,6 +371,12 @@ class IsChildOfFilterMatch(Rule):
def name(self):
return 'Is a child of filter match'
def description(self):
return _("Matches the person that is a child of someone matched by a filter")
def category(self):
return _('Family filters')
def apply(self,db,p):
self.orig = p
@ -397,7 +411,7 @@ class IsDescendantFamilyOf(Rule):
return _('Descendant filters')
def description(self):
return _("Matches people that are descendants or the spouse "
return _("Matches people that are descendants or the spouse "
"of a descendant of a specified person")
def apply(self,db,p):
@ -423,7 +437,6 @@ class IsDescendantFamilyOf(Rule):
if s:
if self.search(s,0):
return 1
return 0
#-------------------------------------------------------------------------
@ -434,7 +447,7 @@ class IsDescendantFamilyOf(Rule):
class IsAncestorOf(Rule):
"""Rule that checks for a person that is an ancestor of a specified person"""
labels = [ _('ID:') ]
labels = [ _('ID:'), _('Inclusive:') ]
def __init__(self,list):
Rule.__init__(self,list)
@ -444,12 +457,22 @@ class IsAncestorOf(Rule):
def name(self):
return 'Is an ancestor of'
def description(self):
return _("Matches people that are ancestors of a specified person")
def category(self):
return _("Ancestral filters")
def apply(self,db,p):
self.orig = p
if int(self.list[1]):
first = 0
else:
first = 1
if not self.init:
self.init = 1
root = db.getPerson(self.list[0])
self.init_ancestor_list(root,1)
self.init_ancestor_list(root,first)
return self.map.has_key(p.getId())
def init_ancestor_list(self,p,first):
@ -477,7 +500,7 @@ class IsAncestorOfFilterMatch(IsAncestorOf):
"""Rule that checks for a person that is an ancestor of
someone matched by a filter"""
labels = [ _('Filter name:') ]
labels = [ _('Filter name:'), _('Inclusive:') ]
def __init__(self,list):
IsAncestorOf.__init__(self,list)
@ -485,14 +508,25 @@ class IsAncestorOfFilterMatch(IsAncestorOf):
def name(self):
return 'Is an ancestor of filter match'
def description(self):
return _("Matches people that are ancestors "
"of of someone matched by a filter")
def category(self):
return _("Ancestral filters")
def apply(self,db,p):
self.orig = p
if int(self.list[1]):
first = 0
else:
first = 1
if not self.init:
self.init = 1
filter = MatchesFilter(self.list)
filter = MatchesFilter(self.list[0])
for person in db.getPersonMap ().values ():
if filter.apply (db, person):
self.init_ancestor_list (person,1)
self.init_ancestor_list (person,first)
return self.map.has_key(p.getId())
#-------------------------------------------------------------------------
@ -514,6 +548,13 @@ class IsLessThanNthGenerationAncestorOf(Rule):
def name(self):
return 'Is an ancestor of person not more than N generations away'
def description(self):
return _("Matches people that are ancestors "
"of a specified person not more than N generations away")
def category(self):
return _("Ancestral filters")
def apply(self,db,p):
self.orig = p
if not self.init:
@ -559,6 +600,13 @@ class IsMoreThanNthGenerationAncestorOf(Rule):
def name(self):
return 'Is an ancestor of person at least N generations away'
def description(self):
return _("Matches people that are ancestors "
"of a specified person at least N generations away")
def category(self):
return _("Ancestral filters")
def apply(self,db,p):
self.orig = p
if not self.init:
@ -602,6 +650,12 @@ class IsParentOfFilterMatch(Rule):
def name(self):
return 'Is a parent of filter match'
def description(self):
return _("Matches the person that is a parent of someone matched by a filter")
def category(self):
return _('Family filters')
def apply(self,db,p):
self.orig = p
@ -635,6 +689,13 @@ class HasCommonAncestorWith(Rule):
def name(self):
return 'Has a common ancestor with'
def description(self):
return _("Matches people that have a common ancestor "
"with a specified person")
def category(self):
return _("Ancestral filters")
def __init__(self,list):
Rule.__init__(self,list)
# Keys in `ancestor_cache' are ancestors of list[0].
@ -674,6 +735,13 @@ class HasCommonAncestorWithFilterMatch(HasCommonAncestorWith):
def name(self):
return 'Has a common ancestor with filter match'
def description(self):
return _("Matches people that have a common ancestor "
"with someone matched by a filter")
def category(self):
return _("Ancestral filters")
def __init__(self,list):
HasCommonAncestorWith.__init__(self,list)
@ -698,6 +766,12 @@ class IsMale(Rule):
def name(self):
return 'Is a male'
def category(self):
return _('General filters')
def description(self):
return _('Matches all males')
def apply(self,db,p):
return p.getGender() == RelLib.Person.male
@ -722,6 +796,12 @@ class HasEvent(Rule):
def name(self):
return 'Has the personal event'
def description(self):
return _("Matches the person with a personal event of a particular value")
def category(self):
return _('Event filters')
def apply(self,db,p):
for event in p.getEventList():
val = 1
@ -763,6 +843,12 @@ class HasFamilyEvent(Rule):
def name(self):
return 'Has the family event'
def description(self):
return _("Matches the person with a family event of a particular value")
def category(self):
return _('Event filters')
def apply(self,db,p):
for f in p.getFamilyList():
for event in f.getEventList():
@ -797,6 +883,12 @@ class HasRelationship(Rule):
def name(self):
return 'Has the relationships'
def description(self):
return _("Matches the person who has a particular relationship")
def category(self):
return _('Family filters')
def apply(self,db,p):
rel_type = 0
cnt = 0
@ -853,6 +945,12 @@ class HasBirth(Rule):
def name(self):
return 'Has the birth'
def description(self):
return _("Matches the person with a birth of a particular value")
def category(self):
return _('Event filters')
def apply(self,db,p):
event = p.getBirth()
ed = event.getDescription().upper()
@ -887,6 +985,12 @@ class HasDeath(Rule):
def name(self):
return 'Has the death'
def description(self):
return _("Matches the person with a death of a particular value")
def category(self):
return _('Event filters')
def apply(self,db,p):
event = p.getDeath()
ed = event.getDescription().upper()
@ -961,6 +1065,12 @@ class HasNameOf(Rule):
def name(self):
return 'Has a name'
def description(self):
return _("Matches the person with a specified (partial) name")
def category(self):
return _('General filters')
def apply(self,db,p):
self.f = self.list[0]
self.l = self.list[1]
@ -1017,6 +1127,12 @@ class IsSpouseOfFilterMatch(Rule):
def name(self):
return 'Is spouse of filter match'
def description(self):
return _("Matches the person married to someone matching a filter")
def category(self):
return _('Family filters')
def apply(self,db,p):
filter = MatchesFilter (self.list)
for family in p.getFamilyList ():

View File

@ -365,7 +365,7 @@ class BookList:
Saves the current BookList to the associated file.
"""
f = open(self.file,"w")
f.write("<?xml version=\"1.0\"?>\n")
f.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
f.write('<booklist>\n')
for name in self.bookmap.keys():

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000 Donald N. Allingham
# Copyright (C) 2000-2003 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
@ -60,6 +60,24 @@ _name2list = {
}
#-------------------------------------------------------------------------
#
# MyBoolean - check button with standard interface
#
#-------------------------------------------------------------------------
class MyBoolean(gtk.CheckButton):
def __init__(self,label=None):
gtk.CheckButton.__init__(self,label)
self.show()
def get_text(self):
return str(int(self.get_active()))
def set_text(self,val):
is_active = not not int(val)
self.set_active(is_active)
#-------------------------------------------------------------------------
#
# MyInteger - spin button with standard interface
@ -448,6 +466,8 @@ class FilterEditor:
t = MyFilters(self.filterdb.get_filters())
elif _name2list.has_key(v1):
t = MySelect(_name2list[v1])
elif v == 'Inclusive:':
t = MyBoolean(_('Include original person'))
else:
t = MyEntry()
tlist.append(t)