diff --git a/gramps/src/GrampsParser.py b/gramps/src/GrampsParser.py index f472b3785..453c64314 100644 --- a/gramps/src/GrampsParser.py +++ b/gramps/src/GrampsParser.py @@ -339,21 +339,25 @@ class GrampsParser(handler.ContentHandler): #--------------------------------------------------------------------- def start_photo(self,attrs): photo = Photo() - if attrs.has_key("descrip"): - photo.setDescription(u2l(attrs["descrip"])) - src = u2l(attrs["src"]) - if src[0] != os.sep: - photo.setPath("%s%s%s" % (self.base,os.sep,src)) - photo.setPrivate(1) - else: - photo.setPath(src) - photo.setPrivate(0) - if self.family: - self.family.addPhoto(photo) - elif self.source: - self.source.addPhoto(photo) - else: - self.person.addPhoto(photo) + for key in attrs.keys(): + if key == "descrip": + photo.setDescription(u2l(attrs["descrip"])) + elif key == "src": + src = u2l(attrs["src"]) + if src[0] != os.sep: + photo.setPath("%s%s%s" % (self.base,os.sep,src)) + photo.setPrivate(1) + else: + photo.setPath(src) + photo.setPrivate(0) + if self.family: + self.family.addPhoto(photo) + elif self.source: + self.source.addPhoto(photo) + else: + self.person.addPhoto(photo) + else: + photo.addProperty(key,attrs[key]) #--------------------------------------------------------------------- # diff --git a/gramps/src/RelLib.py b/gramps/src/RelLib.py index 485fedc11..5d0a1400e 100644 --- a/gramps/src/RelLib.py +++ b/gramps/src/RelLib.py @@ -46,6 +46,7 @@ class Photo: self.path = "" self.desc = "" self.private = 0 + self.proplist = None def setPath(self,path): self.path = path @@ -65,6 +66,15 @@ class Photo: def getDescription(self): return self.desc + def addProperty(self,key,value): + if self.proplist == None: + self.proplist = { key: value} + else: + self.proplist[key] = value; + + def getPropertyList(self): + return self.proplist + #------------------------------------------------------------------------- # # @@ -854,7 +864,10 @@ class RelDataBase: return self.sourceMap def addPerson(self,person): - index = str(self.pmapIndex) + index = "I%d" % self.pmapIndex + while self.personMap.has_key(index): + self.pmapIndex = self.pmapIndex + 1 + index = "I%d" % self.pmapIndex person.setId(index) self.personMap[index] = person self.pmapIndex = self.pmapIndex + 1 @@ -917,11 +930,7 @@ class RelDataBase: id = str(id) person.setId(id) self.personMap[id] = person - try: - val = int(id) - self.pmapIndex = max(self.pmapIndex,val)+1 - except: - pass + self.pmapIndex = self.pmapIndex+1 return id def findPersonNoMap(self,idVal): @@ -943,7 +952,10 @@ class RelDataBase: return self.smapIndex def addSource(self,source): - index = str(self.smapIndex) + index = "S%d" % self.smapIndex + while self.sourceMap.has_key(index): + self.smapIndex = self.smapIndex + 1 + index = "S%d" % self.smapIndex source.setId(index) self.sourceMap[index] = source self.smapIndex = self.smapIndex + 1 @@ -962,11 +974,7 @@ class RelDataBase: index = str(index) source.setId(index) self.sourceMap[index] = source - try: - val = int(index) - self.smapIndex = max(self.smapIndex,val) + 1 - except: - pass + self.smapIndex = self.smapIndex + 1 return index def findSourceNoMap(self,idVal): @@ -979,11 +987,14 @@ class RelDataBase: return source def newFamily(self): - id = str(self.fmapIndex) + index = "F%d" % self.fmapIndex + while self.familyMap.has_key(index): + self.fmapIndex = self.fmapIndex + 1 + index = "F%d" % self.fmapIndex self.fmapIndex = self.fmapIndex + 1 family = Family() - family.setId(id) - self.familyMap[id] = family + family.setId(index) + self.familyMap[index] = family return family def newFamilyNoMap(self,id): @@ -991,11 +1002,7 @@ class RelDataBase: id = str(id) family.setId(id) self.familyMap[id] = family - try: - val = int(id) - self.fmapIndex = max(self.fmapIndex,val) + 1 - except: - pass + self.fmapIndex = self.fmapIndex + 1 return family def findFamily(self,idVal,map): diff --git a/gramps/src/WriteXML.py b/gramps/src/WriteXML.py index 5aa7a8fcb..453df86c7 100644 --- a/gramps/src/WriteXML.py +++ b/gramps/src/WriteXML.py @@ -262,7 +262,12 @@ def exportData(database, filename, callback): if os.path.dirname(path) == fileroot: path = os.path.basename(path) g.write("\n") + g.write(" descrip=\"" + fix(photo.getDescription()) + "\"") + proplist = photo.getPropertyList() + if proplist: + for key in proplist.keys(): + g.write(' %s="%s"' % (key,proplist[key])) + g.write("/>\n") if len(person.getAddressList()) > 0: g.write("\n") @@ -338,7 +343,12 @@ def exportData(database, filename, callback): if os.path.dirname(path) == fileroot: path = os.path.basename(path) g.write("\n") + g.write(" descrip=\"" + fix(photo.getDescription()) + "\"") + proplist = photo.getPropertyList() + if proplist: + for key in proplist.keys(): + g.write(' %s="%s"' % (key,proplist[key])) + g.write("/>\n") if len(family.getChildList()) > 0: g.write("\n") @@ -374,7 +384,11 @@ def exportData(database, filename, callback): if os.path.dirname(path) == fileroot: path = os.path.basename(path) g.write("\n") + g.write(" descrip=\"" + fix(photo.getDescription()) + "\"") + proplist = photo.getPropertyList() + if proplist: + for key in proplist.keys(): + g.write(' %s="%s"' % (key,proplist[key])) g.write("\n") g.write("\n") diff --git a/gramps/src/gramps.glade b/gramps/src/gramps.glade index 5f7b8c9e8..cc4f3d5a0 100644 --- a/gramps/src/gramps.glade +++ b/gramps/src/gramps.glade @@ -707,7 +707,7 @@ Thu, 07 Dec 2000 14:37:54 GMT 5 - 250,40,70,150,100 + 250,60,70,150,100 GTK_SELECTION_SINGLE True GTK_SHADOW_IN @@ -1743,7 +1743,7 @@ Thu, 21 Dec 2000 20:47:47 GMT 6 - 210,50,50,150,75,50 + 210,60,50,150,75,50 GTK_SELECTION_SINGLE True GTK_SHADOW_IN diff --git a/gramps/src/gramps_main.py b/gramps/src/gramps_main.py index 6447322bc..77a18d793 100755 --- a/gramps/src/gramps_main.py +++ b/gramps/src/gramps_main.py @@ -875,9 +875,9 @@ def save_file(filename): except OSError, msg: GnomeErrorDialog(_("Could not create %s") % filename + "\n" + str(msg)) return - except: - GnomeErrorDialog(_("Could not create %s") % filename) - return +# except: +# GnomeErrorDialog(_("Could not create %s") % filename) +# return database.setSavePath(old_file) utils.clearModified() @@ -1954,11 +1954,11 @@ def load_tree_values(person,index,max,pv_text,tip): bdate = person.getBirth().getDate() ddate = person.getDeath().getDate() if bdate and ddate: - text = msg + "\nb. " + bdate + "\n" + "d. " + ddate + text = "%s\nb. %s\nd. %s" % (msg, bdate,ddate) elif bdate and not ddate: - text = msg + "\nb. " + bdate + text = "%s\nb. %s" % (msg, bdate) elif not bdate and ddate: - text = msg + "\nd. " + ddate + text = "%s\nb. %s" % (msg, ddate) else: text = msg tip[index] = text