From 00f2c326c52383099b6e0c2cd151a0be659a2461 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 13 Jul 2001 04:32:59 +0000 Subject: [PATCH] Allow for ID values to be strings svn: r243 --- gramps/src/EditPerson.py | 10 +++++----- gramps/src/EditSource.py | 6 +++--- gramps/src/Marriage.py | 2 +- gramps/src/RelLib.py | 12 ++++++------ gramps/src/WriteXML.py | 20 ++++++++++---------- gramps/src/gramps_main.py | 8 ++++---- gramps/src/plugins/GraphViz.py | 11 ++++------- gramps/src/plugins/HtmlReport.py | 6 +++--- gramps/src/plugins/Merge.py | 8 ++++---- gramps/src/plugins/WebPage.py | 11 +++++------ gramps/src/plugins/WriteGedcom.py | 8 ++++---- 11 files changed, 49 insertions(+), 53 deletions(-) diff --git a/gramps/src/EditPerson.py b/gramps/src/EditPerson.py index 2d9943dfa..bfcb70b78 100644 --- a/gramps/src/EditPerson.py +++ b/gramps/src/EditPerson.py @@ -183,7 +183,7 @@ class EditPerson: birth = person.getBirth() death = person.getDeath() - self.get_widget("gid").set_text(str(person.getId())) + self.get_widget("gid").set_text(person.getId()) self.event_list.set_column_visibility(3,Config.show_detail) self.name_list.set_column_visibility(1,Config.show_detail) self.attr_list.set_column_visibility(2,Config.show_detail) @@ -228,7 +228,7 @@ class EditPerson: photo_list = person.getPhotoList() if len(photo_list) != 0: thumb = self.db.getSavePath() + os.sep + ".thumb" + \ - os.sep + "i%d.jpg" % self.person.getId() + os.sep + "i%s.jpg" % self.person.getId() RelImage.check_thumb(photo_list[0].getPath(),thumb,const.picWidth) self.load_photo(thumb) @@ -934,7 +934,7 @@ def on_primary_photo_clicked(obj): edit_person_obj.load_images() thumb = edit_person_obj.db.getSavePath() + os.sep + ".thumb" + os.sep + \ - "i%d" % edit_person_obj.person.getId() + "i%s" % edit_person_obj.person.getId() RelImage.mk_thumb(savePhoto,thumb,const.picWidth) edit_person_obj.load_photo(thumb) @@ -1123,7 +1123,7 @@ def on_savephoto_clicked(obj): if os.path.exists(filename) == 0: return - prefix = "i" + str(edit_person_obj.person.getId()) + prefix = "i%s" % edit_person_obj.person.getId() if edit_person_obj.external.get_active() == 1: if os.path.isfile(filename): name = filename @@ -1342,7 +1342,7 @@ def on_convert_to_private(obj): edit_person_obj = obj.get_data("m") photo = edit_person_obj.person.getPhotoList()[edit_person_obj.selectedIcon] - prefix = "i" + str(edit_person_obj.person.getId()) + prefix = "i%s" % edit_person_obj.person.getId() name = RelImage.import_photo(photo.getPath(),edit_person_obj.path,prefix) photo.setPath(name) diff --git a/gramps/src/EditSource.py b/gramps/src/EditSource.py index c5f181aee..5444c9cb3 100644 --- a/gramps/src/EditSource.py +++ b/gramps/src/EditSource.py @@ -101,7 +101,7 @@ class EditSource: self.top = self.top_window.get_widget("sourceEditor") self.top.set_data(SOURCE,self) - if self.source.getId() == -1: + if self.source.getId() == "": self.top_window.get_widget("add_photo").set_sensitive(0) self.top_window.get_widget("delete_photo").set_sensitive(0) @@ -242,7 +242,7 @@ def on_savephoto_clicked(obj): if os.path.exists(filename) == 0: return - prefix = "s" + str(edit_source_obj.source.getId()) + prefix = "s%s" % edit_source_obj.source.getId() if edit_source_obj.external.get_active() == 1: if os.path.isfile(filename): name = filename @@ -313,7 +313,7 @@ def on_convert_to_private(obj): edit_source_obj = obj.get_data("m") photo = edit_source_obj.source.getPhotoList()[edit_source_obj.selectedIcon] - prefix = "i" + str(edit_source_obj.source.getId()) + prefix = "i%s" % edit_source_obj.source.getId() name = RelImage.import_photo(photo.getPath(),edit_source_obj.path,prefix) photo.setPath(name) diff --git a/gramps/src/Marriage.py b/gramps/src/Marriage.py index b8c60547e..8693d3261 100644 --- a/gramps/src/Marriage.py +++ b/gramps/src/Marriage.py @@ -554,7 +554,7 @@ def on_savephoto_clicked(obj): if os.path.exists(filename) == 0: return - prefix = "f" + str(marriage_obj.family.getId()) + prefix = "f%s" % marriage_obj.family.getId() name = RelImage.import_photo(filename,marriage_obj.path,prefix) if name == None: return diff --git a/gramps/src/RelLib.py b/gramps/src/RelLib.py index ff711b7bb..6776d1d53 100644 --- a/gramps/src/RelLib.py +++ b/gramps/src/RelLib.py @@ -297,7 +297,7 @@ class Person: female = 0 def __init__(self): - self.id = -1 + self.id = "" self.PrimaryName = None self.EventList = [] self.FamilyList = [] @@ -342,7 +342,7 @@ class Person: self.urls.append(url) def setId(self,id) : - self.id = id + self.id = str(id) def getId(self) : return self.id @@ -581,7 +581,7 @@ class Family: self.Divorce = None self.type = "" self.EventList = [] - self.id = -1 + self.id = "" self.photoList = [] self.note = Note() self.attributeList = [] @@ -613,7 +613,7 @@ class Family: self.note = obj def setId(self,id) : - self.id = id + self.id = str(id) def getId(self) : return self.id @@ -688,10 +688,10 @@ class Source: self.callno = "" self.note = Note() self.photoList = [] - self.id = -1 + self.id = "" def setId(self,newId): - self.id = newId + self.id = str(newId) def getId(self): return self.id diff --git a/gramps/src/WriteXML.py b/gramps/src/WriteXML.py index 4736a5a13..5aa7a8fcb 100644 --- a/gramps/src/WriteXML.py +++ b/gramps/src/WriteXML.py @@ -114,9 +114,9 @@ def dump_source_ref(g,source_ref): t = source_ref.getText() d = source_ref.getDate().getSaveDate() if p == "" and c == "" and t == "" and d == "": - g.write("\n" % source.getId()) + g.write("\n" % source.getId()) else: - g.write("\n" % source.getId()) + g.write("\n" % source.getId()) write_line(g,"spage",p) writeNote(g,"scomments",c) writeNote(g,"stext",t) @@ -130,7 +130,7 @@ def dump_source_ref(g,source_ref): #------------------------------------------------------------------------- def write_ref(g,label,person): if person: - g.write('<%s ref="%s"/>\n' % (label,str(person.getId()))) + g.write('<%s ref="%s"/>\n' % (label,person.getId())) #------------------------------------------------------------------------- # @@ -139,7 +139,7 @@ def write_ref(g,label,person): #------------------------------------------------------------------------- def write_id(g,label,person): if person: - g.write('<%s id="%s">\n' % (label,str(person.getId()))) + g.write('<%s id="%s">\n' % (label,person.getId())) #------------------------------------------------------------------------- # @@ -150,9 +150,9 @@ def write_family_id(g,family): if family: rel = family.getRelationship() if rel != "": - g.write('\n' % (str(family.getId()),rel)) + g.write('\n' % (family.getId(),rel)) else: - g.write('\n' % str(family.getId())) + g.write('\n' % family.getId()) #------------------------------------------------------------------------- # @@ -229,7 +229,7 @@ def exportData(database, filename, callback): g.write("\n") total = len(personList) + len(familyList) @@ -308,7 +308,7 @@ def exportData(database, filename, callback): write_ref(g,"childof",person.getMainFamily()) for alt in person.getAltFamilyList(): g.write("\n" % \ - (str(alt[0].getId()), alt[1], alt[2])) + (alt[0].getId(), alt[1], alt[2])) for family in person.getFamilyList(): write_ref(g,"parentin",family) @@ -362,7 +362,7 @@ def exportData(database, filename, callback): if len(sourceList) > 0: g.write("\n") for source in sourceList: - g.write("\n") + g.write("\n") write_line(g,"stitle",source.getTitle()) write_line(g,"sauthor",source.getAuthor()) write_line(g,"spubinfo",source.getPubInfo()) @@ -381,7 +381,7 @@ def exportData(database, filename, callback): if len(db.getBookmarks()) > 0: g.write("\n") for person in db.getBookmarks(): - g.write("\n") + g.write("\n") g.write("\n") g.write("\n") diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index db078e944..f22e0b308 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -273,7 +273,7 @@ def redraw_child_list(filter): if filter and person.getMainFamily() != None: continue addChildList.append([utils.phonebook_name(person),birthday(person),\ - str(person.getId())]) + person.getId()]) addChildList.set_row_data(index,person) index = index + 1 @@ -1258,7 +1258,7 @@ def modify_statusbar(): else: pname = Config.nameof(active_person) if Config.status_bar == 1: - name = "[%s] %s" % (str(active_person.getId()),pname) + name = "[%s] %s" % (active_person.getId(),pname) elif Config.status_bar == 2: name = pname for attr in active_person.getAttributeList(): @@ -1859,7 +1859,7 @@ def display_marriage(family): if len(child.getPhotoList()) > 0: attr = attr + "P" - clist.append([Config.nameof(child),str(child.getId()),\ + clist.append([Config.nameof(child),child.getId(),\ gender,birthday(child),status,attr]) clist.set_row_data(i,child) i=i+1 @@ -2011,7 +2011,7 @@ def apply_filter(): gender = const.female bday = person.getBirth().getQuoteDate() dday = person.getDeath().getQuoteDate() - clistadd([gname(name,alt),str(person.getId()), gender,bday, dday],\ + clistadd([gname(name,alt),person.getId(), gender,bday, dday],\ person) i = i + 1 diff --git a/gramps/src/plugins/GraphViz.py b/gramps/src/plugins/GraphViz.py index a9b24ce40..f89121239 100644 --- a/gramps/src/plugins/GraphViz.py +++ b/gramps/src/plugins/GraphViz.py @@ -213,12 +213,10 @@ def dump_person(person_list,file): continue father = family.getFather() if father and father in person_list: - file.write('p' + str(person.getId()) + ' -> p') - file.write(str(father.getId()) + ';\n') + file.write('p%s -> p%s;\n' % (person.getId(), father.getId())) mother = family.getMother() if mother and mother in person_list: - file.write('p' + str(person.getId()) + ' -> p') - file.write(str(mother.getId()) + ';\n') + file.write('p%s -> p%s;\n' % (person.getId(), mother.getId())) ######################################################################### # @@ -231,9 +229,8 @@ def dump_index(person_list,file): for person in person_list: name = person.getPrimaryName().getName() id = person.getId() -# file.write('p' + str(id) + ' [shape=box, fontsize=11, ') - file.write('p' + str(id) + ' [shape=box, ') - file.write('fontname="Arial", label="' + name + '"];\n') + file.write('p%s [shape=box, ' % id) + file.write('fontname="Arial", label="%s"];\n' % name) #------------------------------------------------------------------------ # diff --git a/gramps/src/plugins/HtmlReport.py b/gramps/src/plugins/HtmlReport.py index 14f595893..057827aeb 100644 --- a/gramps/src/plugins/HtmlReport.py +++ b/gramps/src/plugins/HtmlReport.py @@ -369,7 +369,7 @@ def name_or_link(individual, prefix): name = individual.getPrimaryName().getRegularName() if individual in ind_list: id = individual.getId() - return "" + name + "" + return "" + name + "" else: return name @@ -392,7 +392,7 @@ def write_reference(html, parent, prefix): def dump_person(person,prefix,templateTop,templateBottom,targetDir): - filebase = "%s%d.html" % (prefix,person.getId()) + filebase = "%s%s.html" % (prefix,person.getId()) html = open(targetDir + os.sep + filebase,"w") name = person.getPrimaryName().getRegularName() @@ -539,7 +539,7 @@ def dump_index(person_list,filename,prefix,templateTop,templateBottom,targetDir) for person in person_list: name = person.getPrimaryName().getName() id = person.getId() - html.write("%s
\n" % (prefix,id,name)) + html.write("%s
\n" % (prefix,id,name)) for line in templateBottom: html.write(line) diff --git a/gramps/src/plugins/Merge.py b/gramps/src/plugins/Merge.py index 4a46ff807..4f4eeb7b0 100644 --- a/gramps/src/plugins/Merge.py +++ b/gramps/src/plugins/Merge.py @@ -538,8 +538,8 @@ class Merge: else: mother2 = "" - label1 = "%s (%s)" % (_("First Person"),str(person1.getId())) - label2 = "%s (%s)" % (_("Second Person"),str(person2.getId())) + label1 = "%s (%s)" % (_("First Person"),person1.getId()) + label2 = "%s (%s)" % (_("Second Person"),person2.getId()) self.topDialog.get_widget("PersonFrame1").set_label(label1) self.topDialog.get_widget("PersonFrame2").set_label(label2) @@ -613,7 +613,7 @@ class Merge: name = "unknown" else: name = spouse.getPrimaryName().getName() + \ - " (" + str(spouse.getId()) + ")" + " (" + spouse.getId() + ")" self.topDialog.get_widget("spouse1").append([name]) length = min(len(p2list),3) @@ -631,7 +631,7 @@ class Merge: name = "unknown" else: name = spouse.getPrimaryName().getName() + \ - " (" + str(spouse.getId()) + ")" + " (" + spouse.getId() + ")" self.topDialog.get_widget("spouse2").append([name]) self.mergee = person1 diff --git a/gramps/src/plugins/WebPage.py b/gramps/src/plugins/WebPage.py index a9f521bc7..fca29252d 100644 --- a/gramps/src/plugins/WebPage.py +++ b/gramps/src/plugins/WebPage.py @@ -177,7 +177,7 @@ class IndividualPage: self.doc.start_paragraph("Data") if person: if person in self.list: - self.doc.start_link("i%s.html" % str(person.getId())) + self.doc.start_link("i%s.html" % person.getId()) self.doc.write_text(person.getPrimaryName().getRegularName()) if person in self.list: self.doc.end_link() @@ -215,7 +215,7 @@ class IndividualPage: # #-------------------------------------------------------------------- def create_page(self): - filebase = "i%d.html" % (self.person.getId()) + filebase = "i%s.html" % self.person.getId() self.doc.open("%s%s%s" % (self.dir,os.sep,filebase)) photo_list = self.person.getPhotoList() @@ -378,7 +378,7 @@ class IndividualPage: self.doc.start_cell("NormalCell",2) self.doc.start_paragraph("Spouse") if spouse: - self.doc.start_link("i%s.html" % str(spouse.getId())) + self.doc.start_link("i%s.html" % spouse.getId()) self.doc.write_text(spouse.getPrimaryName().getRegularName()) self.doc.end_link() else: @@ -410,7 +410,7 @@ class IndividualPage: first = 0 else: self.doc.write_text('\n') - self.doc.start_link("i%s.html" % str(child.getId())) + self.doc.start_link("i%s.html" % child.getId()) self.doc.write_text(child.getPrimaryName().getRegularName()) self.doc.end_link() self.doc.end_paragraph() @@ -760,8 +760,7 @@ def dump_index(person_list,styles,template,html_dir): person_list.sort(sort.by_last_name) for person in person_list: name = person.getPrimaryName().getName() - id = person.getId() - doc.start_link("i%s.html" % str(person.getId())) + doc.start_link("i%s.html" % person.getId()) doc.write_text(name) doc.end_link() doc.newline() diff --git a/gramps/src/plugins/WriteGedcom.py b/gramps/src/plugins/WriteGedcom.py index 319198912..304a97dc8 100644 --- a/gramps/src/plugins/WriteGedcom.py +++ b/gramps/src/plugins/WriteGedcom.py @@ -333,7 +333,7 @@ def write_person_name(g,name,nick): def write_source_ref(g,level,ref): if ref.getBase() == None: return - g.write("%d SOUR @S%s@\n" % (level,str(ref.getBase().getId()))) + g.write("%d SOUR @S%s@\n" % (level,ref.getBase().getId())) if ref.getPage() != "": g.write("%d PAGE %s\n" % (level+1,ref.getPage())) if ref.getText() != "" or ref.getDate().getDate() != "": @@ -425,11 +425,11 @@ def write_person(g,person): family = person.getMainFamily() if family != None and family in family_list: - g.write("1 FAMC @F%s@\n" % str(family.getId())) + g.write("1 FAMC @F%s@\n" % family.getId()) g.write("2 PEDI birth\n") for family in person.getAltFamilyList(): - g.write("1 FAMC @F%s@\n" % str(family[0].getId())) + g.write("1 FAMC @F%s@\n" % family[0].getId()) if string.lower(family[1]) == "adopted": g.write("2 PEDI adopted\n") @@ -537,7 +537,7 @@ def exportData(database, filename): g.write("1 CHIL @I%s@\n" % person.getId()) for source in source_list: - g.write("0 @S%s@ SOUR\n" % str(source.getId())) + g.write("0 @S%s@ SOUR\n" % source.getId()) if source.getTitle() != "": g.write("1 TITL %s\n" % cnvtxt(source.getTitle())) if source.getAuthor() != "":