* src/RelLib.py: Remove the personTable, since it is no longer needed
with the dropping of ZODB, and we don't have to worry about keeping personTable and personMap in sync. Add sort field to Name class. * src/GrampsParser.py: build the primary sort name * src/GrampsXML.py: remove personTable references * src/Find.py: don't user personTable svn: r2595
This commit is contained in:
parent
2a6c2b5298
commit
ffd5e3b265
@ -154,8 +154,9 @@ class FindPerson(FindBase):
|
|||||||
task - function to call to change the active person"""
|
task - function to call to change the active person"""
|
||||||
|
|
||||||
FindBase.__init__(self,task,_("Find Person"),db,valid_map)
|
FindBase.__init__(self,task,_("Find Person"),db,valid_map)
|
||||||
self.list = db.personTable.values()
|
self.list = []
|
||||||
self.list.sort()
|
for val in db.sortPersonKeys():
|
||||||
|
self.list.append(db.getPersonDisplay(val))
|
||||||
|
|
||||||
def get_value(self,id):
|
def get_value(self,id):
|
||||||
return self.db.getPerson(id)
|
return self.db.getPerson(id)
|
||||||
|
@ -671,6 +671,7 @@ class GrampsParser:
|
|||||||
if self.name.getType() == "":
|
if self.name.getType() == "":
|
||||||
self.name.setType("Birth Name")
|
self.name.setType("Birth Name")
|
||||||
self.person.setPrimaryName (self.name)
|
self.person.setPrimaryName (self.name)
|
||||||
|
self.person.getPrimaryName().build_sort_name()
|
||||||
self.name = None
|
self.name = None
|
||||||
|
|
||||||
def stop_ref(self,tag):
|
def stop_ref(self,tag):
|
||||||
@ -883,7 +884,6 @@ class GrampsParser:
|
|||||||
self.name.setType("Also Known As")
|
self.name.setType("Also Known As")
|
||||||
self.name = None
|
self.name = None
|
||||||
|
|
||||||
|
|
||||||
def startElement(self,tag,attrs):
|
def startElement(self,tag,attrs):
|
||||||
|
|
||||||
self.func_list[self.func_index] = (self.func,self.tlist)
|
self.func_list[self.func_index] = (self.func,self.tlist)
|
||||||
|
@ -39,10 +39,8 @@ class GrampsXML(RelLib.GrampsDB):
|
|||||||
|
|
||||||
def load(self,name,callback):
|
def load(self,name,callback):
|
||||||
ReadXML.loadData(self,name,callback)
|
ReadXML.loadData(self,name,callback)
|
||||||
self.personTable = {}
|
|
||||||
for key in self.personMap.keys():
|
for key in self.personMap.keys():
|
||||||
person = self.personMap[key]
|
person = self.personMap[key]
|
||||||
self.personTable[key] = person.getDisplayInfo()
|
|
||||||
self.addSurname(person.getPrimaryName().getSurname())
|
self.addSurname(person.getPrimaryName().getSurname())
|
||||||
|
|
||||||
self.placeTable = {}
|
self.placeTable = {}
|
||||||
|
@ -858,7 +858,6 @@ class Address(DataObj):
|
|||||||
"""returns the postal code of the Address"""
|
"""returns the postal code of the Address"""
|
||||||
return self.postal
|
return self.postal
|
||||||
|
|
||||||
|
|
||||||
class Name(DataObj):
|
class Name(DataObj):
|
||||||
"""Provides name information about a person. A person may have more
|
"""Provides name information about a person. A person may have more
|
||||||
that one name throughout his or her life."""
|
that one name throughout his or her life."""
|
||||||
@ -874,6 +873,7 @@ class Name(DataObj):
|
|||||||
self.Title = source.Title
|
self.Title = source.Title
|
||||||
self.type = source.type
|
self.type = source.type
|
||||||
self.Prefix = source.Prefix
|
self.Prefix = source.Prefix
|
||||||
|
self.sname = source.sname
|
||||||
else:
|
else:
|
||||||
self.FirstName = ""
|
self.FirstName = ""
|
||||||
self.Surname = ""
|
self.Surname = ""
|
||||||
@ -881,6 +881,7 @@ class Name(DataObj):
|
|||||||
self.Title = ""
|
self.Title = ""
|
||||||
self.type = "Birth Name"
|
self.type = "Birth Name"
|
||||||
self.Prefix = ""
|
self.Prefix = ""
|
||||||
|
self.sname = '@'
|
||||||
|
|
||||||
def getSurnamePrefix(self):
|
def getSurnamePrefix(self):
|
||||||
return self.Prefix
|
return self.Prefix
|
||||||
@ -896,17 +897,29 @@ class Name(DataObj):
|
|||||||
"""returns the type of the Name instance"""
|
"""returns the type of the Name instance"""
|
||||||
return self.type
|
return self.type
|
||||||
|
|
||||||
|
def build_sort_name(self):
|
||||||
|
if self.Surname:
|
||||||
|
self.sname = "%-25s%-30s%s" % (self.Surname.upper(),self.FirstName.upper(),self.Suffix.upper())
|
||||||
|
else:
|
||||||
|
self.sname = "@"
|
||||||
|
|
||||||
def setFirstName(self,name):
|
def setFirstName(self,name):
|
||||||
"""sets the given name for the Name instance"""
|
"""sets the given name for the Name instance"""
|
||||||
self.FirstName = name
|
self.FirstName = name
|
||||||
|
self.build_sort_name()
|
||||||
|
|
||||||
def setSurname(self,name):
|
def setSurname(self,name):
|
||||||
"""sets the surname (or last name) for the Name instance"""
|
"""sets the surname (or last name) for the Name instance"""
|
||||||
self.Surname = name
|
self.Surname = name
|
||||||
|
self.build_sort_name()
|
||||||
|
|
||||||
def setSuffix(self,name):
|
def setSuffix(self,name):
|
||||||
"""sets the suffix (such as Jr., III, etc.) for the Name instance"""
|
"""sets the suffix (such as Jr., III, etc.) for the Name instance"""
|
||||||
self.Suffix = name
|
self.Suffix = name
|
||||||
|
self.build_sort_name()
|
||||||
|
|
||||||
|
def getSortName(self):
|
||||||
|
return self.sname
|
||||||
|
|
||||||
def getFirstName(self):
|
def getFirstName(self):
|
||||||
"""returns the given name for the Name instance"""
|
"""returns the given name for the Name instance"""
|
||||||
@ -1123,7 +1136,7 @@ class Person(SourceNote):
|
|||||||
dday = self.getDeath().getDateObj()
|
dday = self.getDeath().getDateObj()
|
||||||
return [ GrampsCfg.display_name(self),self.id,gender,
|
return [ GrampsCfg.display_name(self),self.id,gender,
|
||||||
bday.getQuoteDate(), dday.getQuoteDate(),
|
bday.getQuoteDate(), dday.getQuoteDate(),
|
||||||
sort.build_sort_name(self.getPrimaryName()),
|
self.getPrimaryName().getSortName(),
|
||||||
sort.build_sort_date(bday),sort.build_sort_date(dday),
|
sort.build_sort_date(bday),sort.build_sort_date(dday),
|
||||||
GrampsCfg.display_surname(self.PrimaryName)]
|
GrampsCfg.display_surname(self.PrimaryName)]
|
||||||
|
|
||||||
@ -2145,7 +2158,6 @@ class GrampsDB:
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""creates a new GrampsDB"""
|
"""creates a new GrampsDB"""
|
||||||
self.surnames = []
|
self.surnames = []
|
||||||
self.personTable = {}
|
|
||||||
self.personMap = {}
|
self.personMap = {}
|
||||||
self.placeTable = {}
|
self.placeTable = {}
|
||||||
self.placeMap = {}
|
self.placeMap = {}
|
||||||
@ -2180,36 +2192,34 @@ class GrampsDB:
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
def getPersonLength(self):
|
def getPersonLength(self):
|
||||||
return len(self.personTable)
|
return len(self.personMap)
|
||||||
|
|
||||||
def getPersonKeys(self):
|
def getPersonKeys(self):
|
||||||
return self.personTable.keys()
|
return self.personMap.keys()
|
||||||
|
|
||||||
def sortbyname(self,f,s):
|
def sortbyname(self,f,s):
|
||||||
return cmp(self.personTable[f][5],self.personTable[s][5])
|
n1 = self.personMap[f].PrimaryName.sname
|
||||||
|
n2 = self.personMap[s].PrimaryName.sname
|
||||||
|
return cmp(n1,n2)
|
||||||
|
|
||||||
def sortPersonKeys(self):
|
def sortPersonKeys(self):
|
||||||
keys = self.personTable.keys()
|
keys = self.personMap.keys()
|
||||||
if type(keys) == type([]):
|
if type(keys) == type([]):
|
||||||
keys.sort(self.sortbyname)
|
keys.sort(self.sortbyname)
|
||||||
return keys
|
return keys
|
||||||
|
|
||||||
def getPersonDisplay(self,key):
|
def getPersonDisplay(self,key):
|
||||||
return self.personTable[key]
|
return self.personMap[key].getDisplayInfo()
|
||||||
|
|
||||||
def buildPersonDisplay(self,nkey,okey=None):
|
def buildPersonDisplay(self,nkey,okey=None):
|
||||||
if nkey != okey and okey != None:
|
|
||||||
del self.personTable[okey]
|
|
||||||
person = self.personMap[nkey]
|
person = self.personMap[nkey]
|
||||||
self.personTable[nkey] = person.getDisplayInfo()
|
|
||||||
self.addSurname(person.getPrimaryName().getSurname())
|
self.addSurname(person.getPrimaryName().getSurname())
|
||||||
|
|
||||||
def rebuildPersonTable(self):
|
def rebuildPersonTable(self):
|
||||||
for key in self.personTable.keys():
|
pass
|
||||||
self.personTable[key] = self.personMap[key].getDisplayInfo()
|
|
||||||
|
|
||||||
def buildPlaceDisplay(self,nkey,okey=None):
|
def buildPlaceDisplay(self,nkey,okey=None):
|
||||||
if nkey != okey and okey != None:
|
if okey and nkey != okey:
|
||||||
del self.placeTable[okey]
|
del self.placeTable[okey]
|
||||||
self.placeTable[nkey] = self.placeMap[nkey].getDisplayInfo()
|
self.placeTable[nkey] = self.placeMap[nkey].getDisplayInfo()
|
||||||
|
|
||||||
@ -2274,7 +2284,6 @@ class GrampsDB:
|
|||||||
|
|
||||||
self.surnames = []
|
self.surnames = []
|
||||||
self.personMap = {}
|
self.personMap = {}
|
||||||
self.personTable = {}
|
|
||||||
self.sourceMap = {}
|
self.sourceMap = {}
|
||||||
self.sourceTable = {}
|
self.sourceTable = {}
|
||||||
self.placeMap = {}
|
self.placeMap = {}
|
||||||
@ -2395,7 +2404,7 @@ class GrampsDB:
|
|||||||
"""returns a list of all Attribute types assocated with Person
|
"""returns a list of all Attribute types assocated with Person
|
||||||
instances in the database"""
|
instances in the database"""
|
||||||
map = {}
|
map = {}
|
||||||
for key in self.personTable.keys():
|
for key in self.personMap.keys():
|
||||||
person = self.personMap[key]
|
person = self.personMap[key]
|
||||||
for attr in person.getAttributeList():
|
for attr in person.getAttributeList():
|
||||||
map[attr.getType()] = 1
|
map[attr.getType()] = 1
|
||||||
@ -2434,7 +2443,6 @@ class GrampsDB:
|
|||||||
def removePerson(self,id):
|
def removePerson(self,id):
|
||||||
self.genderStats.uncount_person (self.personMap[id])
|
self.genderStats.uncount_person (self.personMap[id])
|
||||||
del self.personMap[id]
|
del self.personMap[id]
|
||||||
del self.personTable[id]
|
|
||||||
|
|
||||||
def removeSource(self,id):
|
def removeSource(self,id):
|
||||||
del self.sourceMap[id]
|
del self.sourceMap[id]
|
||||||
@ -2442,7 +2450,6 @@ class GrampsDB:
|
|||||||
|
|
||||||
def addPersonAs(self,person):
|
def addPersonAs(self,person):
|
||||||
self.personMap[person.getId()] = person
|
self.personMap[person.getId()] = person
|
||||||
self.personTable[person.getId()] = person.getDisplayInfo()
|
|
||||||
self.genderStats.count_person (person, self)
|
self.genderStats.count_person (person, self)
|
||||||
return person.getId()
|
return person.getId()
|
||||||
|
|
||||||
@ -2454,7 +2461,6 @@ class GrampsDB:
|
|||||||
index = self.iprefix % self.pmapIndex
|
index = self.iprefix % self.pmapIndex
|
||||||
person.setId(index)
|
person.setId(index)
|
||||||
self.personMap[index] = person
|
self.personMap[index] = person
|
||||||
self.personTable[index] = person.getDisplayInfo()
|
|
||||||
self.pmapIndex = self.pmapIndex + 1
|
self.pmapIndex = self.pmapIndex + 1
|
||||||
self.genderStats.count_person (person, self)
|
self.genderStats.count_person (person, self)
|
||||||
return index
|
return index
|
||||||
@ -2474,7 +2480,6 @@ class GrampsDB:
|
|||||||
else:
|
else:
|
||||||
person = Person()
|
person = Person()
|
||||||
map[idVal] = self.addPerson(person)
|
map[idVal] = self.addPerson(person)
|
||||||
self.personTable[map[idVal]] = person.getDisplayInfo()
|
|
||||||
self.genderStats.count_person (person, self)
|
self.genderStats.count_person (person, self)
|
||||||
return person
|
return person
|
||||||
|
|
||||||
@ -2488,7 +2493,6 @@ class GrampsDB:
|
|||||||
person.id = val
|
person.id = val
|
||||||
self.personMap[val] = person
|
self.personMap[val] = person
|
||||||
self.pmapIndex = self.pmapIndex+1
|
self.pmapIndex = self.pmapIndex+1
|
||||||
self.personTable[val] = person.getDisplayInfo()
|
|
||||||
self.genderStats.count_person (person, self)
|
self.genderStats.count_person (person, self)
|
||||||
return person
|
return person
|
||||||
|
|
||||||
@ -2499,7 +2503,6 @@ class GrampsDB:
|
|||||||
person.setId(id)
|
person.setId(id)
|
||||||
self.personMap[id] = person
|
self.personMap[id] = person
|
||||||
self.pmapIndex = self.pmapIndex+1
|
self.pmapIndex = self.pmapIndex+1
|
||||||
self.personTable[id] = person.getDisplayInfo()
|
|
||||||
self.genderStats.count_person (person, self)
|
self.genderStats.count_person (person, self)
|
||||||
return id
|
return id
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user