Fix integer/string problem in RelLib

svn: r244
This commit is contained in:
Don Allingham 2001-07-13 05:16:15 +00:00
parent 00f2c326c5
commit 38b417b6f8

View File

@ -854,7 +854,7 @@ class RelDataBase:
return self.sourceMap return self.sourceMap
def addPerson(self,person): def addPerson(self,person):
index = self.pmapIndex index = str(self.pmapIndex)
person.setId(index) person.setId(index)
self.personMap[index] = person self.personMap[index] = person
self.pmapIndex = self.pmapIndex + 1 self.pmapIndex = self.pmapIndex + 1
@ -905,6 +905,7 @@ class RelDataBase:
return map.keys() return map.keys()
def findPerson(self,idVal,map): def findPerson(self,idVal,map):
idVal = str(idVal)
if map.has_key(idVal): if map.has_key(idVal):
person = self.personMap[map[idVal]] person = self.personMap[map[idVal]]
else: else:
@ -913,13 +914,18 @@ class RelDataBase:
return person return person
def addPersonNoMap(self,person,id): def addPersonNoMap(self,person,id):
id = str(id)
person.setId(id) person.setId(id)
self.personMap[id] = person self.personMap[id] = person
self.pmapIndex = max(self.pmapIndex,id)+1 try:
val = int(id)
self.pmapIndex = max(self.pmapIndex,val)+1
except:
pass
return id return id
def findPersonNoMap(self,idVal): def findPersonNoMap(self,idVal):
val = int(idVal) val = str(idVal)
if self.personMap.has_key(val): if self.personMap.has_key(val):
person = self.personMap[val] person = self.personMap[val]
else: else:
@ -937,13 +943,14 @@ class RelDataBase:
return self.smapIndex return self.smapIndex
def addSource(self,source): def addSource(self,source):
index = self.smapIndex index = str(self.smapIndex)
source.setId(index) source.setId(index)
self.sourceMap[index] = source self.sourceMap[index] = source
self.smapIndex = self.smapIndex + 1 self.smapIndex = self.smapIndex + 1
return index return index
def findSource(self,idVal,map): def findSource(self,idVal,map):
idVal = str(idVal)
if map.has_key(idVal): if map.has_key(idVal):
source = self.sourceMap[map[idVal]] source = self.sourceMap[map[idVal]]
else: else:
@ -952,13 +959,18 @@ class RelDataBase:
return source return source
def addSourceNoMap(self,source,index): def addSourceNoMap(self,source,index):
index = str(index)
source.setId(index) source.setId(index)
self.sourceMap[index] = source self.sourceMap[index] = source
self.smapIndex = max(self.smapIndex,index) + 1 try:
val = int(index)
self.smapIndex = max(self.smapIndex,val) + 1
except:
pass
return index return index
def findSourceNoMap(self,idVal): def findSourceNoMap(self,idVal):
val = int(idVal) val = str(idVal)
if self.sourceMap.has_key(val): if self.sourceMap.has_key(val):
source = self.sourceMap[val] source = self.sourceMap[val]
else: else:
@ -967,7 +979,7 @@ class RelDataBase:
return source return source
def newFamily(self): def newFamily(self):
id = self.fmapIndex id = str(self.fmapIndex)
self.fmapIndex = self.fmapIndex + 1 self.fmapIndex = self.fmapIndex + 1
family = Family() family = Family()
family.setId(id) family.setId(id)
@ -975,13 +987,19 @@ class RelDataBase:
return family return family
def newFamilyNoMap(self,id): def newFamilyNoMap(self,id):
self.fmapIndex = max(self.fmapIndex,id) + 1
family = Family() family = Family()
id = str(id)
family.setId(id) family.setId(id)
self.familyMap[id] = family self.familyMap[id] = family
try:
val = int(id)
self.fmapIndex = max(self.fmapIndex,val) + 1
except:
pass
return family return family
def findFamily(self,idVal,map): def findFamily(self,idVal,map):
idVal = str(idVal)
if map.has_key(idVal): if map.has_key(idVal):
family = self.familyMap[map[idVal]] family = self.familyMap[map[idVal]]
else: else:
@ -990,7 +1008,7 @@ class RelDataBase:
return family return family
def findFamilyNoMap(self,idVal): def findFamilyNoMap(self,idVal):
val = int(idVal) val = str(idVal)
if self.familyMap.has_key(val): if self.familyMap.has_key(val):
family = self.familyMap[val] family = self.familyMap[val]
else: else: