* src/ChooseParents.py: Fix constants.

* src/FamilyView.py: Fix constants.
* src/PedView.py: Fix constants.
* src/ReadGedcom.py: Fix constants.
* src/ReadXML.py: Fix constants.
* src/SelectChild.py: Fix constants.
* src/WriteXML.py: Fix constants.


svn: r4718
This commit is contained in:
Alex Roitman 2005-05-27 20:32:33 +00:00
parent 29f33e9db9
commit 1baf572544
8 changed files with 81 additions and 74 deletions

View File

@ -12,6 +12,14 @@
* src/GrampsBSDDB.py (upgrade_2): Use proper constants. * src/GrampsBSDDB.py (upgrade_2): Use proper constants.
* src/RelLib.py: Move constants out to const.py.in. * src/RelLib.py: Move constants out to const.py.in.
* src/ChooseParents.py: Fix constants.
* src/FamilyView.py: Fix constants.
* src/PedView.py: Fix constants.
* src/ReadGedcom.py: Fix constants.
* src/ReadXML.py: Fix constants.
* src/SelectChild.py: Fix constants.
* src/WriteXML.py: Fix constants.
2005-05-27 Richard Taylor <rjt-gramps@thegrindstone.me.uk> 2005-05-27 Richard Taylor <rjt-gramps@thegrindstone.me.uk>
* src/EditRepository.py: polish Repository Ref UI * src/EditRepository.py: polish Repository Ref UI
* src/RelLib.py: merge minor changes from HEAD * src/RelLib.py: merge minor changes from HEAD

View File

@ -147,8 +147,8 @@ class ChooseParents:
frel = fr frel = fr
break break
else: else:
mrel = RelLib.Person.CHILD_REL_BIRTH mrel = const.CHILD_BIRTH
frel = RelLib.Person.CHILD_REL_BIRTH frel = const.CHILD_BIRTH
if self.family: if self.family:
self.type = self.family.get_relationship() self.type = self.family.get_relationship()
@ -455,12 +455,12 @@ class ChooseParents:
try: try:
mother_rel = self.mcombo.get_active() mother_rel = self.mcombo.get_active()
except KeyError: except KeyError:
mother_rel = RelLib.Person.CHILD_REL_BIRTH mother_rel = const.CHILD_BIRTH
try: try:
father_rel = self.fcombo.get_active() father_rel = self.fcombo.get_active()
except KeyError: except KeyError:
father_rel = RelLib.Person.CHILD_REL_BIRTH father_rel = const.CHILD_BIRTH
trans = self.db.transaction_begin() trans = self.db.transaction_begin()
if self.father or self.mother: if self.father or self.mother:
@ -630,8 +630,8 @@ class ModifyParents:
self.fcombo = self.glade.get_widget('fcombo') self.fcombo = self.glade.get_widget('fcombo')
self.mcombo = self.glade.get_widget('mcombo') self.mcombo = self.glade.get_widget('mcombo')
self.orig_mrel = RelLib.Person.CHILD_REL_BIRTH self.orig_mrel = const.CHILD_BIRTH
self.orig_frel = RelLib.Person.CHILD_REL_BIRTH self.orig_frel = const.CHILD_BIRTH
for (f,mr,fr) in self.person.get_parent_family_handle_list(): for (f,mr,fr) in self.person.get_parent_family_handle_list():
if f == self.family.get_handle(): if f == self.family.get_handle():
self.orig_mrel = mr self.orig_mrel = mr

View File

@ -685,10 +685,10 @@ class FamilyView:
if not self.person: if not self.person:
return return
person = RelLib.Person() person = RelLib.Person()
if self.person.get_gender() == RelLib.Person.MALE: if self.person.get_gender() == const.MALE:
person.set_gender(RelLib.Person.FEMALE) person.set_gender(const.FEMALE)
else: else:
person.set_gender(RelLib.Person.MALE) person.set_gender(const.MALE)
try: try:
EditPerson.EditPerson(self.parent, person, self.parent.db, EditPerson.EditPerson(self.parent, person, self.parent.db,
self.new_spouse_after_edit) self.new_spouse_after_edit)
@ -712,7 +712,7 @@ class FamilyView:
old_person.add_family_handle(fhandle) old_person.add_family_handle(fhandle)
new_person.add_family_handle(fhandle) new_person.add_family_handle(fhandle)
if self.person.get_gender() == RelLib.Person.MALE: if self.person.get_gender() == const.MALE:
family.set_mother_handle(epo.person.get_handle()) family.set_mother_handle(epo.person.get_handle())
family.set_father_handle(self.person.get_handle()) family.set_father_handle(self.person.get_handle())
else: else:
@ -761,7 +761,7 @@ class FamilyView:
self.family = RelLib.Family() self.family = RelLib.Family()
self.parent.db.add_family(self.family,trans) self.parent.db.add_family(self.family,trans)
person.add_family_handle(self.family.get_handle()) person.add_family_handle(self.family.get_handle())
if person.get_gender() == RelLib.Person.MALE: if person.get_gender() == const.MALE:
self.family.set_father_handle(person) self.family.set_father_handle(person)
else: else:
self.family.set_mother_handle(person) self.family.set_mother_handle(person)
@ -783,7 +783,7 @@ class FamilyView:
family = RelLib.Family() family = RelLib.Family()
self.parent.db.add_family(family,trans) self.parent.db.add_family(family,trans)
person.add_family_handle(family.get_handle()) person.add_family_handle(family.get_handle())
if person.get_gender() == RelLib.Person.MALE: if person.get_gender() == const.MALE:
family.set_father_handle(person.get_handle()) family.set_father_handle(person.get_handle())
else: else:
family.set_mother_handle(person.get_handle()) family.set_mother_handle(person.get_handle())
@ -792,8 +792,8 @@ class FamilyView:
family.add_child_handle(new_person.get_handle()) family.add_child_handle(new_person.get_handle())
new_person.add_parent_family_handle(family.get_handle(), new_person.add_parent_family_handle(family.get_handle(),
RelLib.Person.CHILD_REL_BIRTH, const.CHILD_BIRTH,
RelLib.Person.CHILD_REL_BIRTH) const.CHILD_BIRTH)
self.parent.db.commit_person(new_person,trans) self.parent.db.commit_person(new_person,trans)
self.parent.db.commit_family(family,trans) self.parent.db.commit_family(family,trans)
self.parent.db.transaction_commit(trans,_("Add Child to Family")) self.parent.db.transaction_commit(trans,_("Add Child to Family"))
@ -1434,7 +1434,7 @@ class FamilyView:
family = RelLib.Family() family = RelLib.Family()
self.parent.db.add_family(family,trans) self.parent.db.add_family(family,trans)
person.add_family_handle(family.get_handle()) person.add_family_handle(family.get_handle())
if person.get_gender() == RelLib.Person.MALE: if person.get_gender() == const.MALE:
family.set_father_handle(person.get_handle()) family.set_father_handle(person.get_handle())
else: else:
family.set_mother_handle(person.get_handle()) family.set_mother_handle(person.get_handle())
@ -1443,8 +1443,8 @@ class FamilyView:
family.add_child_handle(new_person.get_handle()) family.add_child_handle(new_person.get_handle())
new_person.add_parent_family_handle(family.get_handle(), new_person.add_parent_family_handle(family.get_handle(),
RelLib.Person.CHILD_REL_BIRTH, const.CHILD_BIRTH,
RelLib.Person.CHILD_REL_BIRTH) const.CHILD_BIRTH)
self.parent.db.commit_person(new_person,trans) self.parent.db.commit_person(new_person,trans)
self.parent.db.commit_family(family,trans) self.parent.db.commit_family(family,trans)
self.parent.db.transaction_commit(trans,_("Add Child to Family")) self.parent.db.transaction_commit(trans,_("Add Child to Family"))
@ -1546,7 +1546,7 @@ class FamilyView:
sel_data.set(sel_data.target, bits_per, data) sel_data.set(sel_data.target, bits_per, data)
def north_american(self,val): def north_american(self,val):
if self.person.get_gender() == RelLib.Person.MALE: if self.person.get_gender() == const.MALE:
pname = self.person.get_primary_name() pname = self.person.get_primary_name()
return (pname.get_surname_prefix(),pname.get_surname()) return (pname.get_surname_prefix(),pname.get_surname())
elif self.family: elif self.family:
@ -1579,7 +1579,7 @@ class FamilyView:
def icelandic(self,val): def icelandic(self,val):
fname = "" fname = ""
if self.person.get_gender() == RelLib.Person.MALE: if self.person.get_gender() == const.MALE:
fname = self.person.get_primary_name().get_first_name() fname = self.person.get_primary_name().get_first_name()
elif self.family: elif self.family:
f = self.family.get_father_handle() f = self.family.get_father_handle()

View File

@ -280,9 +280,9 @@ class PedigreeView:
tooltip.set_tip(text, self.format_person(lst[i][0], 11)) tooltip.set_tip(text, self.format_person(lst[i][0], 11))
text.set_alignment(0.0,0.0) text.set_alignment(0.0,0.0)
gender = lst[i][0].get_gender() gender = lst[i][0].get_gender()
if gender == RelLib.Person.MALE: if gender == const.MALE:
text.modify_bg( gtk.STATE_NORMAL, text.get_colormap().alloc_color("#F5FFFF")) text.modify_bg( gtk.STATE_NORMAL, text.get_colormap().alloc_color("#F5FFFF"))
elif gender == RelLib.Person.FEMALE: elif gender == const.FEMALE:
text.modify_bg( gtk.STATE_NORMAL, text.get_colormap().alloc_color("#FFF5FF")) text.modify_bg( gtk.STATE_NORMAL, text.get_colormap().alloc_color("#FFF5FF"))
else: else:
text.modify_bg( gtk.STATE_NORMAL, text.get_colormap().alloc_color("#FFFFF5")) text.modify_bg( gtk.STATE_NORMAL, text.get_colormap().alloc_color("#FFFFF5"))
@ -423,8 +423,8 @@ class PedigreeView:
else: else:
return return
if family_handle: if family_handle:
mrel = m != RelLib.Person.CHILD_REL_BIRTH mrel = m != const.CHILD_BIRTH
frel = f != RelLib.Person.CHILD_REL_BIRTH frel = f != const.CHILD_BIRTH
family = self.db.get_family_from_handle(family_handle) family = self.db.get_family_from_handle(family_handle)
if family != None: if family != None:

View File

@ -83,15 +83,15 @@ file_systems = {
"SMBFS" : _('Networked Windows file system') "SMBFS" : _('Networked Windows file system')
} }
rel_types = (RelLib.Person.CHILD_REL_BIRTH, rel_types = (const.CHILD_BIRTH,
RelLib.Person.CHILD_REL_UNKWN, const.CHILD_UNKNOWN,
RelLib.Person.CHILD_REL_NONE) const.CHILD_NONE)
pedi_type = { pedi_type = {
'birth' : RelLib.Person.CHILD_REL_BIRTH, 'birth' : const.CHILD_BIRTH,
'natural': RelLib.Person.CHILD_REL_BIRTH, 'natural': const.CHILD_BIRTH,
'adopted': RelLib.Person.CHILD_REL_ADOPT, 'adopted': const.CHILD_ADOPTED,
'foster' : RelLib.Person.CHILD_REL_FOST, 'foster' : const.CHILD_FOSTER,
} }
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -781,8 +781,8 @@ class GedcomParser:
self.barf(level+1) self.barf(level+1)
def parse_ftw_relations(self,level): def parse_ftw_relations(self,level):
mrel = RelLib.Person.CHILD_REL_BIRTH mrel = const.CHILD_BIRTH
frel = RelLib.Person.CHILD_REL_BIRTH frel = const.CHILD_BIRTH
while 1: while 1:
matches = self.get_next() matches = self.get_next()
@ -791,17 +791,17 @@ class GedcomParser:
return (mrel,frel) return (mrel,frel)
# FTW # FTW
elif matches[1] == "_FREL": elif matches[1] == "_FREL":
frel = pedi_type.get(matches[2].lower(),RelLib.Person.CHILD_REL_BIRTH) frel = pedi_type.get(matches[2].lower(),const.CHILD_BIRTH)
# FTW # FTW
elif matches[1] == "_MREL": elif matches[1] == "_MREL":
mrel = pedi_type.get(matches[2].lower(),RelLib.Person.CHILD_REL_BIRTH) mrel = pedi_type.get(matches[2].lower(),const.CHILD_BIRTH)
elif matches[1] == "ADOP": elif matches[1] == "ADOP":
mrel = RelLib.Person.CHILD_REL_ADOPT mrel = const.CHILD_ADOPTED
frel = RelLib.Person.CHILD_REL_ADOPT frel = const.CHILD_ADOPTED
# Legacy # Legacy
elif matches[1] == "_STAT": elif matches[1] == "_STAT":
mrel = RelLib.Person.CHILD_REL_BIRTH mrel = const.CHILD_BIRTH
frel = RelLib.Person.CHILD_REL_BIRTH frel = const.CHILD_BIRTH
#mrel = matches[2] #mrel = matches[2]
#frel = matches[2] #frel = matches[2]
# Legacy _PREF # Legacy _PREF
@ -972,11 +972,11 @@ class GedcomParser:
note = self.parse_note(matches,self.person,1,note) note = self.parse_note(matches,self.person,1,note)
elif matches[1] == "SEX": elif matches[1] == "SEX":
if matches[2] == '': if matches[2] == '':
self.person.set_gender(RelLib.Person.UNKNOWN) self.person.set_gender(const.UNKNOWN)
elif matches[2][0] == "M": elif matches[2][0] == "M":
self.person.set_gender(RelLib.Person.MALE) self.person.set_gender(const.MALE)
else: else:
self.person.set_gender(RelLib.Person.FEMALE) self.person.set_gender(const.FEMALE)
elif matches[1] in [ "BAPL", "ENDL", "SLGC" ]: elif matches[1] in [ "BAPL", "ENDL", "SLGC" ]:
lds_ord = RelLib.LdsOrd() lds_ord = RelLib.LdsOrd()
if matches[1] == "BAPL": if matches[1] == "BAPL":
@ -1003,8 +1003,7 @@ class GedcomParser:
else: else:
if ftype in rel_types: if ftype in rel_types:
self.person.add_parent_family_handle( self.person.add_parent_family_handle(
handle, RelLib.Person.CHILD_REL_BIRTH, handle, const.CHILD_BIRTH, const.CHILD_BIRTH)
RelLib.Person.CHILD_REL_BIRTH)
else: else:
if self.person.get_main_parents_family_handle() == handle: if self.person.get_main_parents_family_handle() == handle:
self.person.set_main_parent_family_handle(None) self.person.set_main_parent_family_handle(None)
@ -1130,7 +1129,7 @@ class GedcomParser:
return None return None
def parse_famc_type(self,level): def parse_famc_type(self,level):
ftype = RelLib.Person.CHILD_REL_BIRTH ftype = const.CHILD_BIRTH
note = "" note = ""
while 1: while 1:
matches = self.get_next() matches = self.get_next()
@ -1478,8 +1477,8 @@ class GedcomParser:
self.barf(level+1) self.barf(level+1)
def parse_adopt_famc(self,level): def parse_adopt_famc(self,level):
mrel = RelLib.Person.CHILD_REL_ADOPT mrel = const.CHILD_ADOPTED
frel = RelLib.Person.CHILD_REL_ADOPT frel = const.CHILD_ADOPTED
while 1: while 1:
matches = self.get_next() matches = self.get_next()
if int(matches[0]) < level: if int(matches[0]) < level:
@ -1487,9 +1486,9 @@ class GedcomParser:
return (mrel,frel) return (mrel,frel)
elif matches[1] == "ADOP": elif matches[1] == "ADOP":
if matches[2] == "HUSB": if matches[2] == "HUSB":
mrel = RelLib.Person.CHILD_REL_BIRTH mrel = const.CHILD_BIRTH
elif matches[2] == "WIFE": elif matches[2] == "WIFE":
frel = RelLib.Person.CHILD_REL_BIRTH frel = const.CHILD_BIRTH
else: else:
self.barf(level+1) self.barf(level+1)
return None return None

View File

@ -808,16 +808,16 @@ class GrampsParser:
try: try:
mrel = const.child_rel_notrans.index(attrs["mrel"]) mrel = const.child_rel_notrans.index(attrs["mrel"])
except: except:
mrel = RelLib.Person.CHILD_REL_NONE mrel = const.CHILD_NONE
else: else:
mrel = RelLib.Person.CHILD_REL_BIRTH mrel = const.CHILD_BIRTH
if attrs.has_key("frel"): if attrs.has_key("frel"):
try: try:
frel = const.child_rel_notrans.index(attrs["frel"]) frel = const.child_rel_notrans.index(attrs["frel"])
except: except:
frel = RelLib.Person.CHILD_REL_NONE frel = const.CHILD_NONE
else: else:
frel = RelLib.Person.CHILD_REL_BIRTH frel = const.CHILD_BIRTH
self.person.add_parent_family_handle(family.get_handle(),mrel,frel) self.person.add_parent_family_handle(family.get_handle(),mrel,frel)
def start_parentin(self,attrs): def start_parentin(self,attrs):
@ -1242,11 +1242,11 @@ class GrampsParser:
def stop_gender(self,tag): def stop_gender(self,tag):
t = tag t = tag
if t == "M": if t == "M":
self.person.set_gender (RelLib.Person.MALE) self.person.set_gender (const.MALE)
elif t == "F": elif t == "F":
self.person.set_gender (RelLib.Person.FEMALE) self.person.set_gender (const.FEMALE)
else: else:
self.person.set_gender (RelLib.Person.UNKNOWN) self.person.set_gender (const.UNKNOWN)
def stop_stitle(self,tag): def stop_stitle(self,tag):
self.source.set_title(tag) self.source.set_title(tag)

View File

@ -2,7 +2,7 @@
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
# Copyright (C) 2000-2004 Donald N. Allingham # Copyright (C) 2000-2005 Donald N. Allingham
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -89,14 +89,14 @@ class SelectChild:
self.mrel = self.xml.get_widget("mrel_combo") self.mrel = self.xml.get_widget("mrel_combo")
self.frel = self.xml.get_widget("frel_combo") self.frel = self.xml.get_widget("frel_combo")
self.build_list(self.mrel,RelLib.Person.CHILD_REL_BIRTH) self.build_list(self.mrel,const.CHILD_BIRTH)
self.build_list(self.frel,RelLib.Person.CHILD_REL_BIRTH) self.build_list(self.frel,const.CHILD_BIRTH)
if self.family: if self.family:
father = self.db.get_person_from_handle(self.family.get_father_handle()) father = self.db.get_person_from_handle(self.family.get_father_handle())
mother = self.db.get_person_from_handle(self.family.get_mother_handle()) mother = self.db.get_person_from_handle(self.family.get_mother_handle())
else: else:
if self.person.get_gender() == RelLib.Person.MALE: if self.person.get_gender() == const.MALE:
self.mrel.set_sensitive(False) self.mrel.set_sensitive(False)
else: else:
self.frel.set_sensitive(False) self.frel.set_sensitive(False)
@ -237,9 +237,9 @@ class SelectChild:
for idval in person_list: for idval in person_list:
person = self.db.get_person_from_handle(idval) person = self.db.get_person_from_handle(idval)
name = NameDisplay.displayer.display(person) name = NameDisplay.displayer.display(person)
if person.gender == RelLib.Person.MALE: if person.gender == const.MALE:
gender = _("male") gender = _("male")
elif person.gender == RelLib.Person.FEMALE: elif person.gender == const.FEMALE:
gender = _("female") gender = _("female")
else: else:
gender = _("unknown") gender = _("unknown")
@ -296,7 +296,7 @@ class SelectChild:
self.db.add_family(self.family,trans) self.db.add_family(self.family,trans)
self.person.add_family_handle(self.family.get_handle()) self.person.add_family_handle(self.family.get_handle())
self.db.commit_person(self.person,trans) self.db.commit_person(self.person,trans)
if self.person.get_gender() == RelLib.Person.MALE: if self.person.get_gender() == const.MALE:
self.family.set_father_handle(self.person.get_handle()) self.family.set_father_handle(self.person.get_handle())
else: else:
self.family.set_mother_handle(self.person.get_handle()) self.family.set_mother_handle(self.person.get_handle())
@ -312,15 +312,15 @@ class SelectChild:
mrel = self.mrel.get_active() mrel = self.mrel.get_active()
mother = self.db.get_person_from_handle(self.family.get_mother_handle()) mother = self.db.get_person_from_handle(self.family.get_mother_handle())
if mother and mother.get_gender() != RelLib.Person.FEMALE: if mother and mother.get_gender() != const.FEMALE:
if mrel == RelLib.Person.CHILD_REL_BIRTH: if mrel == const.CHILD_BIRTH:
mrel = RelLib.Person.CHILD_REL_UNKWN mrel = const.CHILD_UNKNOWN
frel = self.frel.get_active() frel = self.frel.get_active()
father = self.db.get_person_from_handle(self.family.get_father_handle()) father = self.db.get_person_from_handle(self.family.get_father_handle())
if father and father.get_gender() !=RelLib.Person.MALE: if father and father.get_gender() != const.MALE:
if frel == RelLib.Person.CHILD_REL_BIRTH: if frel == const.CHILD_BIRTH:
frel = RelLib.Person.CHILD_REL_UNKWN frel = const.CHILD_UNKNOWN
select_child.add_parent_family_handle(self.family.get_handle(), select_child.add_parent_family_handle(self.family.get_handle(),
mrel,frel) mrel,frel)
@ -336,7 +336,7 @@ class SelectChild:
self.redraw_child_list(not obj.get_active()) self.redraw_child_list(not obj.get_active())
def north_american(self,val): def north_american(self,val):
if self.person.get_gender() == RelLib.Person.MALE: if self.person.get_gender() == const.MALE:
return self.person.get_primary_name().get_surname() return self.person.get_primary_name().get_surname()
elif self.family: elif self.family:
f = self.family.get_father_handle() f = self.family.get_father_handle()
@ -367,7 +367,7 @@ class SelectChild:
def icelandic(self,val): def icelandic(self,val):
fname = "" fname = ""
if self.person.get_gender() == RelLib.Person.MALE: if self.person.get_gender() == const.MALE:
fname = self.person.get_primary_name().get_first_name() fname = self.person.get_primary_name().get_first_name()
elif self.family: elif self.family:
f = self.family.get_father_handle() f = self.family.get_father_handle()

View File

@ -253,9 +253,9 @@ class XmlWriter:
count += 1 count += 1
self.write_id("person",person,2) self.write_id("person",person,2)
if person.get_gender() == RelLib.Person.MALE: if person.get_gender() == const.MALE:
self.write_line("gender","M",3) self.write_line("gender","M",3)
elif person.get_gender() == RelLib.Person.FEMALE: elif person.get_gender() == const.FEMALE:
self.write_line("gender","F",3) self.write_line("gender","F",3)
else: else:
self.write_line("gender","U",3) self.write_line("gender","U",3)
@ -298,11 +298,11 @@ class XmlWriter:
self.write_url_list(person.get_url_list()) self.write_url_list(person.get_url_list())
for alt in person.get_parent_family_handle_list(): for alt in person.get_parent_family_handle_list():
if alt[1] != RelLib.Person.CHILD_REL_BIRTH: if alt[1] != const.CHILD_BIRTH:
mrel=' mrel="%s"' % const.child_rel_notrans[alt[1]] mrel=' mrel="%s"' % const.child_rel_notrans[alt[1]]
else: else:
mrel='' mrel=''
if alt[2] != RelLib.Person.CHILD_REL_BIRTH: if alt[2] != const.CHILD_BIRTH:
frel=' frel="%s"' % const.child_rel_notrans[alt[2]] frel=' frel="%s"' % const.child_rel_notrans[alt[2]]
else: else:
frel='' frel=''