* various: const to RelLib transitition.

svn: r4800
This commit is contained in:
Martin Hawlisch 2005-06-07 19:22:10 +00:00
parent 16c906d7cb
commit f16f41cbda
10 changed files with 76 additions and 73 deletions

View File

@ -1,3 +1,6 @@
2005-06-07 Martin Hawlisch <Martin.Hawlisch@gmx.de>
* various: const to RelLib transitition.
2005-06-07 Alex Roitman <shura@gramps-project.org>
* src/EventView.py (build_columns): Do not artificially create
an extra column.

View File

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

View File

@ -793,8 +793,8 @@ class FamilyView:
# TODO: Add child ordered by birth day
family.add_child_handle(new_person.get_handle())
new_person.add_parent_family_handle(family.get_handle(),
const.CHILD_BIRTH,
const.CHILD_BIRTH)
RelLib.Person.CHILD_BIRTH,
RelLib.Person.CHILD_BIRTH)
self.parent.db.commit_person(new_person,trans)
self.parent.db.commit_family(family,trans)
self.parent.db.transaction_commit(trans,_("Add Child to Family"))
@ -1449,8 +1449,8 @@ class FamilyView:
family.add_child_handle(new_person.get_handle())
new_person.add_parent_family_handle(family.get_handle(),
const.CHILD_BIRTH,
const.CHILD_BIRTH)
RelLib.Person.CHILD_BIRTH,
RelLib.Person.CHILD_BIRTH)
self.parent.db.commit_person(new_person,trans)
self.parent.db.commit_family(family,trans)
self.parent.db.transaction_commit(trans,_("Add Child to Family"))

View File

@ -1415,7 +1415,7 @@ class HaveAltFamilies(Rule):
def apply(self,db,handle):
p = db.get_person_from_handle(handle)
for (fam,rel1,rel2) in p.get_parent_family_handle_list():
if rel1 == const.CHILD_ADOPTED or rel2 == const.CHILD_ADOPTED:
if rel1 == RelLib.Person.CHILD_ADOPTED or rel2 == RelLib.Person.CHILD_ADOPTED:
return 1
return 0

View File

@ -518,11 +518,11 @@ class GrampsBSDDB(GrampsDbBase):
try:
mrel = child_rel_notrans.index(mrel)
except:
mrel = const.CHILD_BIRTH
mrel = RelLib.Person.CHILD_BIRTH
try:
frel = child_rel_notrans.index(frel)
except:
frel = const.CHILD_BIRTH
frel = RelLib.Person.CHILD_BIRTH
new_list.append((f,mrel,frel))
person.parent_family_list = new_list
self.commit_person(person,trans)

View File

@ -425,8 +425,8 @@ class PedigreeView:
else:
return
if family_handle:
mrel = m != const.CHILD_BIRTH
frel = f != const.CHILD_BIRTH
mrel = m != RelLib.Person.CHILD_BIRTH
frel = f != RelLib.Person.CHILD_BIRTH
family = self.db.get_family_from_handle(family_handle)
if family != None:

View File

@ -878,16 +878,16 @@ class GrampsParser:
try:
mrel = const.child_rel_notrans.index(attrs["mrel"])
except:
mrel = const.CHILD_NONE
mrel = RelLib.Person.CHILD_NONE
else:
mrel = const.CHILD_BIRTH
mrel = RelLib.Person.CHILD_BIRTH
if attrs.has_key("frel"):
try:
frel = const.child_rel_notrans.index(attrs["frel"])
except:
frel = const.CHILD_NONE
frel = RelLib.Person.CHILD_NONE
else:
frel = const.CHILD_BIRTH
frel = RelLib.Person.CHILD_BIRTH
self.person.add_parent_family_handle(family.get_handle(),mrel,frel)
def start_parentin(self,attrs):

View File

@ -89,8 +89,8 @@ class SelectChild:
self.mrel = self.xml.get_widget("mrel_combo")
self.frel = self.xml.get_widget("frel_combo")
self.build_list(self.mrel,const.CHILD_BIRTH)
self.build_list(self.frel,const.CHILD_BIRTH)
self.build_list(self.mrel,RelLib.Person.CHILD_BIRTH)
self.build_list(self.frel,RelLib.Person.CHILD_BIRTH)
if self.family:
father = self.db.get_person_from_handle(self.family.get_father_handle())
@ -314,14 +314,14 @@ class SelectChild:
mrel = self.mrel.get_active()
mother = self.db.get_person_from_handle(self.family.get_mother_handle())
if mother and mother.get_gender() != RelLib.Person.FEMALE:
if mrel == const.CHILD_BIRTH:
mrel = const.CHILD_UNKNOWN
if mrel == RelLib.Person.CHILD_BIRTH:
mrel = RelLib.Person.CHILD_UNKNOWN
frel = self.frel.get_active()
father = self.db.get_person_from_handle(self.family.get_father_handle())
if father and father.get_gender() != RelLib.Person.MALE:
if frel == const.CHILD_BIRTH:
frel = const.CHILD_UNKNOWN
if frel == RelLib.Person.CHILD_BIRTH:
frel = RelLib.Person.CHILD_UNKNOWN
select_child.add_parent_family_handle(self.family.get_handle(),
mrel,frel)

View File

@ -298,11 +298,11 @@ class XmlWriter:
self.write_url_list(person.get_url_list())
for alt in person.get_parent_family_handle_list():
if alt[1] != const.CHILD_BIRTH:
if alt[1] != RelLib.Person.CHILD_BIRTH:
mrel=' mrel="%s"' % const.child_rel_notrans[alt[1]]
else:
mrel=''
if alt[2] != const.CHILD_BIRTH:
if alt[2] != RelLib.Person.CHILD_BIRTH:
frel=' frel="%s"' % const.child_rel_notrans[alt[2]]
else:
frel=''

View File

@ -294,12 +294,12 @@ class TestcaseGenerator:
def generate_broken_relations(self):
# Create a family, that links to father and mother, but father does not link back
person1_h = self.generate_person(const.MALE,"Broken1","Family links to this person, but person does not link back")
person2_h = self.generate_person(const.FEMALE,"Broken1",None)
person1_h = self.generate_person(RelLib.Person.MALE,"Broken1","Family links to this person, but person does not link back")
person2_h = self.generate_person(RelLib.Person.FEMALE,"Broken1",None)
fam = RelLib.Family()
fam.set_father_handle(person1_h)
fam.set_mother_handle(person2_h)
fam.set_relationship(const.FAMILY_MARRIED)
fam.set_relationship(RelLib.Family.MARRIED)
fam_h = self.db.add_family(fam,self.trans)
#person1 = self.db.get_person_from_handle(person1_h)
#person1.add_family_handle(fam_h)
@ -310,12 +310,12 @@ class TestcaseGenerator:
self.commit_transaction() # COMMIT TRANSACTION STEP
# Create a family, that misses the link to the father
person1_h = self.generate_person(const.MALE,"Broken2",None)
person2_h = self.generate_person(const.FEMALE,"Broken2",None)
person1_h = self.generate_person(RelLib.Person.MALE,"Broken2",None)
person2_h = self.generate_person(RelLib.Person.FEMALE,"Broken2",None)
fam = RelLib.Family()
#fam.set_father_handle(person1_h)
fam.set_mother_handle(person2_h)
fam.set_relationship(const.FAMILY_MARRIED)
fam.set_relationship(RelLib.Family.MARRIED)
fam_h = self.db.add_family(fam,self.trans)
person1 = self.db.get_person_from_handle(person1_h)
person1.add_family_handle(fam_h)
@ -326,12 +326,12 @@ class TestcaseGenerator:
self.commit_transaction() # COMMIT TRANSACTION STEP
# Create a family, that misses the link to the mother
person1_h = self.generate_person(const.MALE,"Broken3",None)
person2_h = self.generate_person(const.FEMALE,"Broken3",None)
person1_h = self.generate_person(RelLib.Person.MALE,"Broken3",None)
person2_h = self.generate_person(RelLib.Person.FEMALE,"Broken3",None)
fam = RelLib.Family()
fam.set_father_handle(person1_h)
#fam.set_mother_handle(person2_h)
fam.set_relationship(const.FAMILY_MARRIED)
fam.set_relationship(RelLib.Family.MARRIED)
fam_h = self.db.add_family(fam,self.trans)
person1 = self.db.get_person_from_handle(person1_h)
person1.add_family_handle(fam_h)
@ -342,12 +342,12 @@ class TestcaseGenerator:
self.commit_transaction() # COMMIT TRANSACTION STEP
# Create a family, that links to father and mother, but father does not link back
person1_h = self.generate_person(const.MALE,"Broken4",None)
person2_h = self.generate_person(const.FEMALE,"Broken4","Family links to this person, but person does not link back")
person1_h = self.generate_person(RelLib.Person.MALE,"Broken4",None)
person2_h = self.generate_person(RelLib.Person.FEMALE,"Broken4","Family links to this person, but person does not link back")
fam = RelLib.Family()
fam.set_father_handle(person1_h)
fam.set_mother_handle(person2_h)
fam.set_relationship(const.FAMILY_MARRIED)
fam.set_relationship(RelLib.Family.MARRIED)
fam_h = self.db.add_family(fam,self.trans)
person1 = self.db.get_person_from_handle(person1_h)
person1.add_family_handle(fam_h)
@ -358,12 +358,12 @@ class TestcaseGenerator:
self.commit_transaction() # COMMIT TRANSACTION STEP
# Create two married people of same sex.
person1_h = self.generate_person(const.MALE,"Broken5",None)
person2_h = self.generate_person(const.MALE,"Broken5",None)
person1_h = self.generate_person(RelLib.Person.MALE,"Broken5",None)
person2_h = self.generate_person(RelLib.Person.MALE,"Broken5",None)
fam = RelLib.Family()
fam.set_father_handle(person1_h)
fam.set_mother_handle(person2_h)
fam.set_relationship(const.FAMILY_MARRIED)
fam.set_relationship(RelLib.Family.MARRIED)
fam_h = self.db.add_family(fam,self.trans)
person1 = self.db.get_person_from_handle(person1_h)
person1.add_family_handle(fam_h)
@ -374,12 +374,12 @@ class TestcaseGenerator:
self.commit_transaction() # COMMIT TRANSACTION STEP
# Create a family, that contains an invalid handle to for the father
#person1_h = self.generate_person(const.MALE,"Broken6",None)
person2_h = self.generate_person(const.FEMALE,"Broken6",None)
#person1_h = self.generate_person(RelLib.Person.MALE,"Broken6",None)
person2_h = self.generate_person(RelLib.Person.FEMALE,"Broken6",None)
fam = RelLib.Family()
fam.set_father_handle("InvalidHandle1")
fam.set_mother_handle(person2_h)
fam.set_relationship(const.FAMILY_MARRIED)
fam.set_relationship(RelLib.Family.MARRIED)
fam_h = self.db.add_family(fam,self.trans)
#person1 = self.db.get_person_from_handle(person1_h)
#person1.add_family_handle(fam_h)
@ -390,12 +390,12 @@ class TestcaseGenerator:
self.commit_transaction() # COMMIT TRANSACTION STEP
# Create a family, that contains an invalid handle to for the mother
person1_h = self.generate_person(const.MALE,"Broken7",None)
#person2_h = self.generate_person(const.FEMALE,"Broken7",None)
person1_h = self.generate_person(RelLib.Person.MALE,"Broken7",None)
#person2_h = self.generate_person(RelLib.Person.FEMALE,"Broken7",None)
fam = RelLib.Family()
fam.set_father_handle(person1_h)
fam.set_mother_handle("InvalidHandle2")
fam.set_relationship(const.FAMILY_MARRIED)
fam.set_relationship(RelLib.Family.MARRIED)
fam_h = self.db.add_family(fam,self.trans)
person1 = self.db.get_person_from_handle(person1_h)
person1.add_family_handle(fam_h)
@ -407,13 +407,13 @@ class TestcaseGenerator:
# Creates a family where the child does not link back to the family
person1_h = self.generate_person(const.MALE,"Broken8",None)
person2_h = self.generate_person(const.FEMALE,"Broken8",None)
person1_h = self.generate_person(RelLib.Person.MALE,"Broken8",None)
person2_h = self.generate_person(RelLib.Person.FEMALE,"Broken8",None)
child_h = self.generate_person(None,"Broken8",None)
fam = RelLib.Family()
fam.set_father_handle(person1_h)
fam.set_mother_handle(person2_h)
fam.set_relationship(const.FAMILY_MARRIED)
fam.set_relationship(RelLib.Family.MARRIED)
fam.add_child_handle(child_h)
fam_h = self.db.add_family(fam,self.trans)
person1 = self.db.get_person_from_handle(person1_h)
@ -428,13 +428,13 @@ class TestcaseGenerator:
self.commit_transaction() # COMMIT TRANSACTION STEP
# Creates a family where the child is not linked, but the child links to the family
person1_h = self.generate_person(const.MALE,"Broken9",None)
person2_h = self.generate_person(const.FEMALE,"Broken9",None)
person1_h = self.generate_person(RelLib.Person.MALE,"Broken9",None)
person2_h = self.generate_person(RelLib.Person.FEMALE,"Broken9",None)
child_h = self.generate_person(None,"Broken9",None)
fam = RelLib.Family()
fam.set_father_handle(person1_h)
fam.set_mother_handle(person2_h)
fam.set_relationship(const.FAMILY_MARRIED)
fam.set_relationship(RelLib.Family.MARRIED)
#fam.add_child_handle(child_h)
fam_h = self.db.add_family(fam,self.trans)
person1 = self.db.get_person_from_handle(person1_h)
@ -444,7 +444,7 @@ class TestcaseGenerator:
person2.add_family_handle(fam_h)
self.db.commit_person(person2,self.trans)
child = self.db.get_person_from_handle(child_h)
child.add_parent_family_handle(fam_h,const.CHILD_BIRTH,const.CHILD_BIRTH)
child.add_parent_family_handle(fam_h,RelLib.Person.CHILD_BIRTH,RelLib.Person.CHILD_BIRTH)
self.db.commit_person(child,self.trans)
self.commit_transaction() # COMMIT TRANSACTION STEP
@ -460,7 +460,7 @@ class TestcaseGenerator:
event_h = self.db.add_event(event,self.trans)
event_ref = RelLib.EventRef()
event_ref.set_reference_handle(event_h)
event_ref.set_role(RelLib.const.ROLE_PRIMARY)
event_ref.set_role(RelLib.EventRef.PRIMARY)
person = self.db.get_person_from_handle(person_h)
person.add_event_ref(event_ref)
self.db.commit_person(person,self.trans)
@ -471,7 +471,7 @@ class TestcaseGenerator:
person = self.db.get_person_from_handle(person_h)
event_ref = RelLib.EventRef()
event_ref.set_reference_handle("InvalidHandle4")
event_ref.set_role(const.ROLE_PRIMARY)
event_ref.set_role(RelLib.EventRef.PRIMARY)
person.set_birth_ref(event_ref)
self.db.commit_person(person,self.trans)
self.commit_transaction() # COMMIT TRANSACTION STEP
@ -481,7 +481,7 @@ class TestcaseGenerator:
person = self.db.get_person_from_handle(person_h)
event_ref = RelLib.EventRef()
event_ref.set_reference_handle("InvalidHandle5")
event_ref.set_role(const.ROLE_PRIMARY)
event_ref.set_role(RelLib.EventRef.PRIMARY)
person.set_death_ref(event_ref)
self.db.commit_person(person,self.trans)
self.commit_transaction() # COMMIT TRANSACTION STEP
@ -491,7 +491,7 @@ class TestcaseGenerator:
person = self.db.get_person_from_handle(person_h)
event_ref = RelLib.EventRef()
event_ref.set_reference_handle("InvalidHandle6")
event_ref.set_role(const.ROLE_PRIMARY)
event_ref.set_role(RelLib.EventRef.PRIMARY)
person.add_event_ref(event_ref)
self.db.commit_person(person,self.trans)
self.commit_transaction() # COMMIT TRANSACTION STEP
@ -503,7 +503,7 @@ class TestcaseGenerator:
event_h = self.db.add_event(event,self.trans)
event_ref = RelLib.EventRef()
event_ref.set_reference_handle(event_h)
event_ref.set_role(const.ROLE_PRIMARY)
event_ref.set_role(RelLib.EventRef.PRIMARY)
person = self.db.get_person_from_handle(person_h)
person.set_birth_ref(event_ref)
self.db.commit_person(person,self.trans)
@ -516,7 +516,7 @@ class TestcaseGenerator:
event_h = self.db.add_event(event,self.trans)
event_ref = RelLib.EventRef()
event_ref.set_reference_handle(event_h)
event_ref.set_role(const.ROLE_PRIMARY)
event_ref.set_role(RelLib.EventRef.PRIMARY)
person = self.db.get_person_from_handle(person_h)
person.set_death_ref(event_ref)
self.db.commit_person(person,self.trans)
@ -529,7 +529,7 @@ class TestcaseGenerator:
event_h = self.db.add_event(event,self.trans)
event_ref = RelLib.EventRef()
event_ref.set_reference_handle(event_h)
event_ref.set_role(const.ROLE_PRIMARY)
event_ref.set_role(RelLib.EventRef.PRIMARY)
person = self.db.get_person_from_handle(person_h)
person.add_event_ref(event_ref)
self.db.commit_person(person,self.trans)
@ -599,12 +599,12 @@ class TestcaseGenerator:
# now add them as birth to new persons
for dateval in dates:
bevent = RelLib.Event()
bevent.set_name("Birth")
bevent.set_type((RelLib.Event.BIRTH, "Birth"))
bevent.set_date_object(dateval)
bevent_h = self.db.add_event(bevent,self.trans)
bevent_ref = RelLib.EventRef()
bevent_ref.set_reference_handle(bevent_h)
bevent_ref.set_role(const.ROLE_PRIMARY)
bevent_ref.set_role(RelLib.EventRef.PRIMARY)
# for the death event display the date as text and parse it back to a new date
ndate = None
try:
@ -627,12 +627,12 @@ class TestcaseGenerator:
devent = RelLib.Event()
devent.set_name("Death")
devent.set_type((RelLib.Event.DEATH,"Death"))
devent.set_date_object(ndate)
devent_h = self.db.add_event(devent,self.trans)
devent_ref = RelLib.EventRef()
devent_ref.set_reference_handle(devent_h)
devent_ref.set_role(const.ROLE_PRIMARY)
devent_ref.set_role(RelLib.EventRef.PRIMARY)
person_h = self.generate_person(None, "DateTest")
person = self.db.get_person_from_handle(person_h)
person.set_birth_ref(bevent_ref)
@ -670,7 +670,7 @@ class TestcaseGenerator:
for i in range(0,randint(1,5)):
for j in range(0,randint(2,5)):
firstname = firstname + choice(syllables2)
if gender == const.FEMALE:
if gender == RelLib.Person.FEMALE:
firstname = firstname + choice(("a","e","i","o","u"))
firstname = firstname + " "
firstname = firstname.title().strip()
@ -712,7 +712,7 @@ class TestcaseGenerator:
self.add_defaults(fam)
fam.set_father_handle(person1_h)
fam.set_mother_handle(person2_h)
fam.set_relationship(const.FAMILY_MARRIED)
fam.set_relationship(RelLib.Family.MARRIED)
fam_h = self.db.add_family(fam,self.trans)
fam = self.db.commit_family(fam,self.trans)
person1 = self.db.get_person_from_handle(person1_h)
@ -730,7 +730,7 @@ class TestcaseGenerator:
fam.add_child_handle(child_h)
self.db.commit_family(fam,self.trans)
child = self.db.get_person_from_handle(child_h)
child.add_parent_family_handle(fam_h,const.CHILD_BIRTH,const.CHILD_BIRTH)
child.add_parent_family_handle(fam_h,RelLib.Person.CHILD_BIRTH,RelLib.Person.CHILD_BIRTH)
self.db.commit_person(child,self.trans)
if randint(0,3) > 0:
self.persons_todo.append(child_h)
@ -756,7 +756,7 @@ class TestcaseGenerator:
fam = RelLib.Family()
fam.set_father_handle(person1_h)
fam.set_mother_handle(person2_h)
fam.set_relationship(const.FAMILY_MARRIED)
fam.set_relationship(RelLib.Family.MARRIED)
fam.add_child_handle(child_h)
fam_h = self.db.add_family(fam,self.trans)
fam = self.db.commit_family(fam,self.trans)
@ -767,7 +767,7 @@ class TestcaseGenerator:
person2.add_family_handle(fam_h)
self.db.commit_person(person2,self.trans)
child.add_parent_family_handle(fam_h,const.CHILD_BIRTH,const.CHILD_BIRTH)
child.add_parent_family_handle(fam_h,RelLib.Person.CHILD_BIRTH,RelLib.Person.CHILD_BIRTH)
self.db.commit_person(child,self.trans)
self.commit_transaction() # COMMIT TRANSACTION STEP
@ -775,12 +775,12 @@ class TestcaseGenerator:
object.add_source_reference(self.default_sourceref)
object.add_media_reference(self.default_mediaref)
e = RelLib.Event()
e.set_name("TestcaseGenerator")
e.set_type((RelLib.Event.CUSTOM,"TestcaseGenerator"))
e.set_place_handle(self.default_place.get_handle())
event_h = self.db.add_event(e, self.trans)
event_ref = RelLib.EventRef()
event_ref.set_reference_handle(event_h)
event_ref.set_role(const.ROLE_PRIMARY)
event_ref.set_role(RelLib.EventRef.PRIMARY)
object.add_event_ref(event_ref)
def commit_transaction(self):