From e41ee1c752c60475c1f05bd0454fb5d70ac59df7 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 21 Jan 2004 02:56:53 +0000 Subject: [PATCH] update svn: r2681 --- gramps2/src/GenericFilter.py | 12 ++-- gramps2/src/const.py.in | 91 ++++++++++++++++------------- gramps2/src/plugins/FilterEditor.py | 22 +++---- 3 files changed, 70 insertions(+), 55 deletions(-) diff --git a/gramps2/src/GenericFilter.py b/gramps2/src/GenericFilter.py index b340bf509..9287d3cb1 100644 --- a/gramps2/src/GenericFilter.py +++ b/gramps2/src/GenericFilter.py @@ -85,7 +85,7 @@ class Rule: labels = [] def __init__(self,list): - assert type(list) == type([]), "Argument is not a list" + assert type(list) == type([]) or list == None, "Argument is not a list" self.list = list def values(self): @@ -113,7 +113,7 @@ class Rule: v = [] for i in range(0,len(self.list)): if self.list[i]: - v.append('%s="%s"' % (_(self.labels[i]),self.list[i])) + v.append('%s="%s"' % (_(self.labels[i]),_(self.list[i]))) return join(v,'; ') #------------------------------------------------------------------------- @@ -917,7 +917,7 @@ class HasEvent(Rule): def __init__(self,list): Rule.__init__(self,list) - if self.list[0]: + if self.list and self.list[0]: self.date = Date.Date() self.date.set(self.list[0]) else: @@ -964,7 +964,7 @@ class HasFamilyEvent(Rule): def __init__(self,list): Rule.__init__(self,list) - if self.list[0]: + if self.list and self.list[0]: self.date = Date.Date() self.date.set(self.list[0]) else: @@ -1066,7 +1066,7 @@ class HasBirth(Rule): def __init__(self,list): Rule.__init__(self,list) - if self.list[0]: + if self.list and self.list[0]: self.date = Date.Date() self.date.set(self.list[0]) else: @@ -1106,7 +1106,7 @@ class HasDeath(Rule): def __init__(self,list): Rule.__init__(self,list) - if self.list[0]: + if self.list and self.list[0]: self.date = Date.Date() self.date.set(self.list[0]) else: diff --git a/gramps2/src/const.py.in b/gramps2/src/const.py.in index d281f5c1f..016c68ec9 100644 --- a/gramps2/src/const.py.in +++ b/gramps2/src/const.py.in @@ -213,7 +213,7 @@ familyConstantEvents = { # #------------------------------------------------------------------------- -_family_events = TransTable( { +family_events = TransTable( { "Alternate Marriage" : _("Alternate Marriage"), "Annulment" : _("Annulment"), "Divorce Filing" : _("Divorce Filing"), @@ -226,10 +226,10 @@ _family_events = TransTable( { }) def display_fevent(st): - return _family_events.find_value(st) + return family_events.find_value(st) def save_fevent(st): - return _family_events.find_key(st) + return family_events.find_key(st) #------------------------------------------------------------------------- # @@ -280,7 +280,7 @@ personalConstantEvents = { # #------------------------------------------------------------------------- -_personal_events = TransTable({ +personal_events = TransTable({ "Adopted" : _("Adopted"), "Alternate Birth" : _("Alternate Birth"), "Alternate Death" : _("Alternate Death"), @@ -319,10 +319,10 @@ _personal_events = TransTable({ }) def display_pevent(st): - return _personal_events.find_value(st) + return personal_events.find_value(st) def save_pevent(st): - return _personal_events.find_key(st) + return personal_events.find_key(st) #------------------------------------------------------------------------- # @@ -331,17 +331,17 @@ def save_pevent(st): # #------------------------------------------------------------------------- def display_event(st): - if _personal_events.has_key(st): - return _personal_events.find_value(st) - if _family_events.has_key(st): - return _family_events.find_value(st) + if personal_events.has_key(st): + return personal_events.find_value(st) + if family_events.has_key(st): + return family_events.find_value(st) return _(st) def save_event(st): - if _personal_events.has_value(st): - return _personal_events.find_key(st) - if _family_events.has_value(st): - return _family_events.find_key(st) + if personal_events.has_value(st): + return personal_events.find_key(st) + if family_events.has_value(st): + return family_events.find_key(st) return st #------------------------------------------------------------------------- @@ -363,7 +363,7 @@ personalConstantAttributes = { # #------------------------------------------------------------------------- -_personal_attributes = TransTable({ +personal_attributes = TransTable({ "Caste" : _("Caste"), "Description" : _("Description"), "Identification Number" : _("Identification Number"), @@ -372,10 +372,10 @@ _personal_attributes = TransTable({ }) def display_pattr(st): - return _personal_attributes.find_value(st) + return personal_attributes.find_value(st) def save_pattr(st): - return _personal_attributes.find_key(st) + return personal_attributes.find_key(st) #------------------------------------------------------------------------- # @@ -386,13 +386,13 @@ familyConstantAttributes = { "Number of Children" : "NCHI", } -_family_attributes = TransTable({"Number of Children" : _("Number of Children")}) +family_attributes = TransTable({"Number of Children" : _("Number of Children")}) def display_fattr(st): - return _family_attributes.find_value(st) + return family_attributes.find_value(st) def save_fattr(st): - return _family_attributes.find_key(st) + return family_attributes.find_key(st) #------------------------------------------------------------------------- # @@ -401,17 +401,17 @@ def save_fattr(st): # #------------------------------------------------------------------------- def display_attr(st): - if _personal_attributes.has_key(st): - return _personal_attributes.find_value(st) - if _family_attributes.has_key(st): - return _family_attributes.find_value(st) + if personal_attributes.has_key(st): + return personal_attributes.find_value(st) + if family_attributes.has_key(st): + return family_attributes.find_value(st) return _(st) def save_attr(st): - if _personal_attributes.has_value(st): - return _personal_attributes.find_key(st) - if _family_attributes.has_value(st): - return _family_attributes.find_key(st) + if personal_attributes.has_value(st): + return personal_attributes.find_key(st) + if family_attributes.has_value(st): + return family_attributes.find_key(st) return _(st) #------------------------------------------------------------------------- @@ -420,25 +420,38 @@ def save_attr(st): # #------------------------------------------------------------------------- -_family_relations = TransTable({ +_frel2def = { _("Married") : _("A legal or common-law relationship between a husband and wife"), _("Unmarried"): _("No legal or common-law relationship between man and woman"), _("Partners") : _("An established relationship between members of the same sex"), _("Unknown") : _("Unknown relationship between a man and woman"), _("Other") : _("An unspecified relationship between a man and woman") +} + +family_relations = TransTable({ + "Married" : _("Married"), + "Unmarried" : _("Unmarried"), + "Partners" : _("Partners"), + "Unknown" : _("Unknown"), + "Other" : _("Other"), }) +#------------------------------------------------------------------------- +# +# +# +#------------------------------------------------------------------------- def relationship_def(txt): - if _family_relations.has_key(txt): - return _family_relations.find_value[txt] + if _frel2def.has_key(txt): + return _frel2def[txt] else: return _("No definition available") def display_frel(st): - return _family_relations.find_value(st) + return family_relations.find_value(st) def save_frel(st): - return _family_relations.find_key(st) + return family_relations.find_key(st) #------------------------------------------------------------------------- # @@ -459,7 +472,7 @@ NameTypesMap = TransTable({ # #------------------------------------------------------------------------- def init_personal_event_list(): - p = _personal_events.get_values() + p = personal_events.get_values() p.sort() return p @@ -469,7 +482,7 @@ def init_personal_event_list(): # #------------------------------------------------------------------------- def init_marriage_event_list(): - p = _family_events.get_values() + p = family_events.get_values() p.sort() return p @@ -479,7 +492,7 @@ def init_marriage_event_list(): # #------------------------------------------------------------------------- def init_personal_attribute_list(): - p = _personal_attributes.get_values() + p = personal_attributes.get_values() p.sort() return p @@ -489,7 +502,7 @@ def init_personal_attribute_list(): # #------------------------------------------------------------------------- def init_family_attribute_list(): - p = _family_attributes.get_values() + p = family_attributes.get_values() p.sort() return p @@ -499,14 +512,14 @@ def init_family_attribute_list(): # #------------------------------------------------------------------------- def init_family_relation_list(): - p = _family_relations.get_values() + p = family_relations.get_values() p.sort() return p personalEvents = init_personal_event_list() personalAttributes = init_personal_attribute_list() marriageEvents = init_marriage_event_list() -defaultMarriageEvent = _family_events.find_value("Marriage") +defaultMarriageEvent = family_events.find_value("Marriage") familyAttributes = init_family_attribute_list() familyRelations = init_family_relation_list() places = [] diff --git a/gramps2/src/plugins/FilterEditor.py b/gramps2/src/plugins/FilterEditor.py index f6d912d31..ac2f372e5 100644 --- a/gramps2/src/plugins/FilterEditor.py +++ b/gramps2/src/plugins/FilterEditor.py @@ -55,11 +55,11 @@ import SelectPerson from gettext import gettext as _ _name2list = { - _('Personal event:') : const.personalEvents, - _('Family event:') : const.marriageEvents, - _('Personal attribute:') : const.personalAttributes, - _('Family attribute:') : const.familyAttributes, - _('Relationship type:') : const.familyRelations, + _('Personal event:') : (const.personalEvents,const.personal_events), + _('Family event:') : (const.marriageEvents,const.family_events), + _('Personal attribute:') : (const.personalAttributes,const.personal_attributes), + _('Family attribute:') : (const.familyAttributes,const.family_attributes), + _('Relationship type:') : (const.familyRelations,const.family_relations), } @@ -196,19 +196,20 @@ class MyID(gtk.HBox): #------------------------------------------------------------------------- class MySelect(gtk.Combo): - def __init__(self,list): + def __init__(self,list,transtable): gtk.Combo.__init__(self) list.sort() self.set_popdown_strings(list) self.set_value_in_list(1,0) self.entry.set_editable(0) + self.transtable = transtable self.show() def get_text(self): - return unicode(self.entry.get_text()) + return self.transtable.find_key(unicode(self.entry.get_text())) def set_text(self,val): - self.entry.set_text(val) + self.entry.set_text(_(val)) #------------------------------------------------------------------------- # @@ -462,7 +463,8 @@ class FilterEditor: elif v == _('Filter name:'): t = MyFilters(self.filterdb.get_filters()) elif _name2list.has_key(v1): - t = MySelect(_name2list[v1]) + data =_name2list[v1] + t = MySelect(data[0],data[1]) elif v == _('Inclusive:'): t = MyBoolean(_('Include original person')) else: @@ -560,7 +562,7 @@ class FilterEditor: def rule_ok(self,obj): name = unicode(self.rule_name.get_text()) class_def = GenericFilter.tasks[name] - obj = class_def([]) + obj = class_def(None) try: page = self.name2page[name] (n,c,v,t) = self.page[page]