Remove getting values from maps. Use the key lists instead
svn: r1027
This commit is contained in:
parent
7d8b6bbb16
commit
aed5a10637
@ -131,12 +131,12 @@ class ChooseParents:
|
||||
self.mother_list.append(["Unknown","",""])
|
||||
self.mother_list.set_row_data(0,None)
|
||||
|
||||
people = self.db.getPersonMap().values()
|
||||
father_index = 1
|
||||
mother_index = 1
|
||||
fsel = 0
|
||||
msel = 0
|
||||
for person in people:
|
||||
for key in self.db.getPersonKeys():
|
||||
person = self.db.getPerson(key)
|
||||
if person == self.person:
|
||||
continue
|
||||
if person.getGender() == RelLib.Person.unknown:
|
||||
@ -180,7 +180,6 @@ class ChooseParents:
|
||||
self.mlabel.set_label(_("Mother"))
|
||||
self.flabel.set_label(_("Father"))
|
||||
|
||||
|
||||
def parent_relation_changed(self,obj):
|
||||
self.old_type = self.type
|
||||
self.type = const.save_frel(obj.get_text())
|
||||
|
@ -324,7 +324,8 @@ class EditPlace:
|
||||
def display_references(self):
|
||||
pevent = []
|
||||
fevent = []
|
||||
for p in self.db.getPersonMap().values():
|
||||
for key in self.db.getPersonKeys():
|
||||
p = self.db.getPerson(key)
|
||||
for event in [p.getBirth(), p.getDeath()] + p.getEventList():
|
||||
if event.getPlace() == self.place:
|
||||
pevent.append((p,event))
|
||||
@ -403,7 +404,8 @@ class DeletePlaceQuery:
|
||||
del self.db.getPlaceMap()[self.place.getId()]
|
||||
Utils.modified()
|
||||
|
||||
for p in self.db.getPersonMap().values():
|
||||
for key in self.db.getPersonKeys():
|
||||
p = self.db.getPerson(key)
|
||||
for event in [p.getBirth(), p.getDeath()] + p.getEventList():
|
||||
if event.getPlace() == self.place:
|
||||
event.setPlace(None)
|
||||
|
@ -103,12 +103,14 @@ class EditSource:
|
||||
f_event_list = []
|
||||
f_attr_list = []
|
||||
p_list = []
|
||||
for p in self.db.getPlaceMap().values():
|
||||
for key in self.db.getPlaceKeys():
|
||||
p = self.db.getPlace(key)
|
||||
name = p.get_title()
|
||||
for sref in p.getSourceRefList():
|
||||
if sref.getBase() == self.source:
|
||||
p_list.append(name)
|
||||
for p in self.db.getPersonMap().values():
|
||||
for key in self.db.getPersonKeys():
|
||||
p = self.db.getPerson(key)
|
||||
name = GrampsCfg.nameof(p)
|
||||
for v in p.getEventList() + [p.getBirth(), p.getDeath()]:
|
||||
for sref in v.getSourceRefList():
|
||||
@ -235,7 +237,8 @@ class DelSrcQuery:
|
||||
del self.db.getSourceMap()[self.source.getId()]
|
||||
Utils.modified()
|
||||
|
||||
for p in self.db.getPersonMap().values():
|
||||
for key in self.db.getPersonKeys():
|
||||
p = self.getPerson(key)
|
||||
for v in p.getEventList() + [p.getBirth(), p.getDeath()]:
|
||||
self.delete_source(v)
|
||||
|
||||
@ -258,8 +261,8 @@ class DelSrcQuery:
|
||||
for p in self.db.getObjectMap().values():
|
||||
self.delete_source(p)
|
||||
|
||||
for p in self.db.getPlaceMap().values():
|
||||
self.delete_source(p)
|
||||
for key in self.db.getPlaceKeys():
|
||||
self.delete_source(self.db.getPlace(key))
|
||||
|
||||
self.update(0)
|
||||
|
||||
|
@ -632,7 +632,8 @@ class GlobalMediaProperties:
|
||||
index = 0
|
||||
ref = self.change_dialog.get_widget("refinfo")
|
||||
ref.connect('button-press-event',self.button_press)
|
||||
for p in self.db.getPersonMap().values():
|
||||
for key in self.db.getPersonKeys():
|
||||
p = self.db.getPerson(key)
|
||||
for o in p.getPhotoList():
|
||||
if o.getReference() == self.object:
|
||||
ref.append([_("Person"),p.getId(),GrampsCfg.nameof(p)])
|
||||
@ -644,13 +645,15 @@ class GlobalMediaProperties:
|
||||
ref.append([_("Family"),p.getId(),Utils.family_name(p)])
|
||||
ref.set_row_data(index,(Marriage.Marriage,p,self.db))
|
||||
index = index + 1
|
||||
for p in self.db.getSourceMap().values():
|
||||
for key in self.db.getSourceKeys():
|
||||
p = self.db.getSource(key)
|
||||
for o in p.getPhotoList():
|
||||
if o.getReference() == self.object:
|
||||
ref.append([_("Source"),p.getId(),p.getTitle()])
|
||||
ref.set_row_data(index,(EditSource.EditSource,p,self.db))
|
||||
index = index + 1
|
||||
for p in self.db.getPlaceMap().values():
|
||||
for key in self.db.getPlaceKeys():
|
||||
p = self.db.getPlace(key)
|
||||
for o in p.getPhotoList():
|
||||
if o.getReference() == self.object:
|
||||
ref.append([_("Place"),p.getId(),p.get_title()])
|
||||
|
@ -2024,7 +2024,8 @@ class GrampsDB(Persistent):
|
||||
"""returns a list of all Attribute types assocated with Person
|
||||
instances in the database"""
|
||||
map = {}
|
||||
for person in self.personMap.values():
|
||||
for key in self.personTable.keys():
|
||||
person = self.personMap[key]
|
||||
for attr in person.getAttributeList():
|
||||
map[attr.getType()] = 1
|
||||
return map.keys()
|
||||
@ -2290,7 +2291,10 @@ class GrampsDB(Persistent):
|
||||
|
||||
def getPlaceKeys(self):
|
||||
return self.placeTable.keys()
|
||||
|
||||
|
||||
def getPlace(self,key):
|
||||
return self.placeMap[key]
|
||||
|
||||
def getPlaceDisplay(self,key):
|
||||
return self.placeTable[key]
|
||||
|
||||
@ -2300,6 +2304,9 @@ class GrampsDB(Persistent):
|
||||
def getSourceDisplay(self,key):
|
||||
return self.sourceTable[key]
|
||||
|
||||
def getSource(self,key):
|
||||
return self.sourceMap[key]
|
||||
|
||||
def buildSourceDisplay(self,nkey,okey=None):
|
||||
if nkey != okey and okey != None:
|
||||
del self.sourceTable[okey]
|
||||
|
@ -72,15 +72,9 @@ def exportData(database, filename, callback):
|
||||
g.write(filename)
|
||||
except:
|
||||
from gnome.ui import GnomeErrorDialog
|
||||
import traceback
|
||||
|
||||
traceback.print_exc()
|
||||
|
||||
fname = os.path.expanduser("~/gramps.err")
|
||||
errfile = open(fname,"w")
|
||||
traceback.print_exc(file=errfile)
|
||||
errfile.close()
|
||||
import DisplayTrace
|
||||
|
||||
DisplayTrace.DisplayTrace()
|
||||
GnomeErrorDialog(_("Failure writing %s, original file restored") % filename)
|
||||
shutil.copy(filename + ".bak", filename)
|
||||
|
||||
@ -156,17 +150,14 @@ class XmlWriter:
|
||||
|
||||
date = string.split(time.ctime(time.time()))
|
||||
owner = self.db.getResearcher()
|
||||
personList = self.db.getPersonMap().values()
|
||||
#personList.sort(sortById)
|
||||
familyList = self.db.getFamilyMap().values()
|
||||
#familyList.sort(sortById)
|
||||
sourceList = self.db.getSourceMap().values()
|
||||
placeList = self.db.getPlaceMap().values()
|
||||
#placeList.sort(sortById)
|
||||
person_len = len(self.db.getPersonKeys())
|
||||
family_len = len(familyList)
|
||||
source_len = len(self.db.getSourceKeys())
|
||||
place_len = len(self.db.getPlaceKeys())
|
||||
objList = self.db.getObjectMap().values()
|
||||
#objList.sort(sortById)
|
||||
|
||||
total = len(personList) + len(familyList) + len(placeList) + len(sourceList)
|
||||
total = person_len + family_len + place_len + source_len
|
||||
|
||||
self.g.write('<?xml version="1.0" encoding="iso-8859-1"?>\n')
|
||||
self.g.write('<!DOCTYPE database SYSTEM "gramps.dtd" []>\n')
|
||||
@ -174,10 +165,10 @@ class XmlWriter:
|
||||
self.g.write(" <header>\n")
|
||||
self.g.write(" <created date=\"%s %s %s\"" % (date[2],string.upper(date[1]),date[4]))
|
||||
self.g.write(" version=\"" + const.version + "\"")
|
||||
self.g.write(" people=\"%d\"" % (len(self.db.getPersonMap().values())))
|
||||
self.g.write(" families=\"%d\"" % len(self.db.getFamilyMap().values()))
|
||||
self.g.write(" sources=\"%d\"" % len(self.db.getSourceMap().values()))
|
||||
self.g.write(" places=\"%d\"/>\n" % len(self.db.getPlaceMap().values()))
|
||||
self.g.write(" people=\"%d\"" % person_len)
|
||||
self.g.write(" families=\"%d\"" % family_len)
|
||||
self.g.write(" sources=\"%d\"" % source_len)
|
||||
self.g.write(" places=\"%d\"/>\n" % place_len)
|
||||
self.g.write(" <researcher>\n")
|
||||
self.write_line("resname",owner.getName(),3)
|
||||
self.write_line("resaddr",owner.getAddress(),3)
|
||||
@ -190,7 +181,7 @@ class XmlWriter:
|
||||
self.g.write(" </researcher>\n")
|
||||
self.g.write(" </header>\n")
|
||||
|
||||
if len(personList) > 0:
|
||||
if person_len > 0:
|
||||
self.g.write(" <people")
|
||||
person = self.db.getDefaultPerson()
|
||||
if person:
|
||||
@ -200,7 +191,8 @@ class XmlWriter:
|
||||
delta = max(int(total/50),1)
|
||||
|
||||
count = 0
|
||||
for person in personList:
|
||||
for key in self.db.getPersonKeys():
|
||||
person = self.db.getPerson(key)
|
||||
if self.callback and count % delta == 0:
|
||||
self.callback(float(count)/float(total))
|
||||
count = count + 1
|
||||
@ -270,7 +262,7 @@ class XmlWriter:
|
||||
self.g.write(" </person>\n")
|
||||
self.g.write(" </people>\n")
|
||||
|
||||
if len(familyList) > 0:
|
||||
if family_len > 0:
|
||||
self.g.write(" <families>\n")
|
||||
|
||||
for family in familyList:
|
||||
@ -299,9 +291,10 @@ class XmlWriter:
|
||||
self.g.write(" </family>\n")
|
||||
self.g.write(" </families>\n")
|
||||
|
||||
if len(sourceList) > 0:
|
||||
if source_len > 0:
|
||||
self.g.write(" <sources>\n")
|
||||
for source in sourceList:
|
||||
for key in self.db.getSourceKeys():
|
||||
source = self.db.getSource(key)
|
||||
if self.callback and count % delta == 0:
|
||||
self.callback(float(count)/float(total))
|
||||
count = count + 1
|
||||
@ -316,9 +309,10 @@ class XmlWriter:
|
||||
self.g.write(" </source>\n")
|
||||
self.g.write(" </sources>\n")
|
||||
|
||||
if len(placeList) > 0:
|
||||
if place_len > 0:
|
||||
self.g.write(" <places>\n")
|
||||
for place in placeList:
|
||||
for key in self.db.getPlaceKeys():
|
||||
place = self.db.getPlace(key)
|
||||
if self.callback and count % delta == 0:
|
||||
self.callback(float(count)/float(total))
|
||||
count = count + 1
|
||||
|
@ -560,14 +560,15 @@ class GedcomParser:
|
||||
self.parse_family_event(event,2)
|
||||
|
||||
def parse_note(self,matches,obj,level,old_note):
|
||||
note = old_note
|
||||
if matches[2] and matches[2][0] == "@":
|
||||
if self.nmap.has_key(matches[2]):
|
||||
self.share_note.append(obj)
|
||||
self.family.setNoteObj(self.nmap[matches[2]])
|
||||
obj.setNoteObj(self.nmap[matches[2]])
|
||||
else:
|
||||
noteobj = Note()
|
||||
self.nmap[matches[2]] = noteobj
|
||||
self.share_note.append(self.family)
|
||||
self.share_note.append(obj)
|
||||
obj.setNoteObj(noteobj)
|
||||
else:
|
||||
if old_note:
|
||||
|
Loading…
Reference in New Issue
Block a user