XML changes

svn: r251
This commit is contained in:
Don Allingham 2001-07-16 02:06:31 +00:00
parent ba8f365e04
commit 92b3a6375d
5 changed files with 71 additions and 46 deletions

View File

@ -339,8 +339,10 @@ class GrampsParser(handler.ContentHandler):
#--------------------------------------------------------------------- #---------------------------------------------------------------------
def start_photo(self,attrs): def start_photo(self,attrs):
photo = Photo() photo = Photo()
if attrs.has_key("descrip"): for key in attrs.keys():
if key == "descrip":
photo.setDescription(u2l(attrs["descrip"])) photo.setDescription(u2l(attrs["descrip"]))
elif key == "src":
src = u2l(attrs["src"]) src = u2l(attrs["src"])
if src[0] != os.sep: if src[0] != os.sep:
photo.setPath("%s%s%s" % (self.base,os.sep,src)) photo.setPath("%s%s%s" % (self.base,os.sep,src))
@ -354,6 +356,8 @@ class GrampsParser(handler.ContentHandler):
self.source.addPhoto(photo) self.source.addPhoto(photo)
else: else:
self.person.addPhoto(photo) self.person.addPhoto(photo)
else:
photo.addProperty(key,attrs[key])
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# #

View File

@ -46,6 +46,7 @@ class Photo:
self.path = "" self.path = ""
self.desc = "" self.desc = ""
self.private = 0 self.private = 0
self.proplist = None
def setPath(self,path): def setPath(self,path):
self.path = path self.path = path
@ -65,6 +66,15 @@ class Photo:
def getDescription(self): def getDescription(self):
return self.desc 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 return self.sourceMap
def addPerson(self,person): 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) person.setId(index)
self.personMap[index] = person self.personMap[index] = person
self.pmapIndex = self.pmapIndex + 1 self.pmapIndex = self.pmapIndex + 1
@ -917,11 +930,7 @@ class RelDataBase:
id = str(id) id = str(id)
person.setId(id) person.setId(id)
self.personMap[id] = person self.personMap[id] = person
try: self.pmapIndex = self.pmapIndex+1
val = int(id)
self.pmapIndex = max(self.pmapIndex,val)+1
except:
pass
return id return id
def findPersonNoMap(self,idVal): def findPersonNoMap(self,idVal):
@ -943,7 +952,10 @@ class RelDataBase:
return self.smapIndex return self.smapIndex
def addSource(self,source): 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) source.setId(index)
self.sourceMap[index] = source self.sourceMap[index] = source
self.smapIndex = self.smapIndex + 1 self.smapIndex = self.smapIndex + 1
@ -962,11 +974,7 @@ class RelDataBase:
index = str(index) index = str(index)
source.setId(index) source.setId(index)
self.sourceMap[index] = source self.sourceMap[index] = source
try: self.smapIndex = self.smapIndex + 1
val = int(index)
self.smapIndex = max(self.smapIndex,val) + 1
except:
pass
return index return index
def findSourceNoMap(self,idVal): def findSourceNoMap(self,idVal):
@ -979,11 +987,14 @@ class RelDataBase:
return source return source
def newFamily(self): 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 self.fmapIndex = self.fmapIndex + 1
family = Family() family = Family()
family.setId(id) family.setId(index)
self.familyMap[id] = family self.familyMap[index] = family
return family return family
def newFamilyNoMap(self,id): def newFamilyNoMap(self,id):
@ -991,11 +1002,7 @@ class RelDataBase:
id = str(id) id = str(id)
family.setId(id) family.setId(id)
self.familyMap[id] = family self.familyMap[id] = family
try: self.fmapIndex = self.fmapIndex + 1
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):

View File

@ -262,7 +262,12 @@ def exportData(database, filename, callback):
if os.path.dirname(path) == fileroot: if os.path.dirname(path) == fileroot:
path = os.path.basename(path) path = os.path.basename(path)
g.write("<img src=\"" + fix(path) + "\"") g.write("<img src=\"" + fix(path) + "\"")
g.write(" descrip=\"" + fix(photo.getDescription()) + "\"/>\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: if len(person.getAddressList()) > 0:
g.write("<addresses>\n") g.write("<addresses>\n")
@ -338,7 +343,12 @@ def exportData(database, filename, callback):
if os.path.dirname(path) == fileroot: if os.path.dirname(path) == fileroot:
path = os.path.basename(path) path = os.path.basename(path)
g.write("<img src=\"" + fix(path) + "\"") g.write("<img src=\"" + fix(path) + "\"")
g.write(" descrip=\"" + fix(photo.getDescription()) + "\"/>\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: if len(family.getChildList()) > 0:
g.write("<childlist>\n") g.write("<childlist>\n")
@ -374,7 +384,11 @@ def exportData(database, filename, callback):
if os.path.dirname(path) == fileroot: if os.path.dirname(path) == fileroot:
path = os.path.basename(path) path = os.path.basename(path)
g.write("<img src=\"" + fix(path) + "\"") g.write("<img src=\"" + fix(path) + "\"")
g.write(" descrip=\"" + fix(photo.getDescription()) + "\"/>\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("</source>\n") g.write("</source>\n")
g.write("</sources>\n") g.write("</sources>\n")

View File

@ -707,7 +707,7 @@
<last_modification_time>Thu, 07 Dec 2000 14:37:54 GMT</last_modification_time> <last_modification_time>Thu, 07 Dec 2000 14:37:54 GMT</last_modification_time>
</signal> </signal>
<columns>5</columns> <columns>5</columns>
<column_widths>250,40,70,150,100</column_widths> <column_widths>250,60,70,150,100</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode> <selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>True</show_titles> <show_titles>True</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type> <shadow_type>GTK_SHADOW_IN</shadow_type>
@ -1743,7 +1743,7 @@
<last_modification_time>Thu, 21 Dec 2000 20:47:47 GMT</last_modification_time> <last_modification_time>Thu, 21 Dec 2000 20:47:47 GMT</last_modification_time>
</signal> </signal>
<columns>6</columns> <columns>6</columns>
<column_widths>210,50,50,150,75,50</column_widths> <column_widths>210,60,50,150,75,50</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode> <selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>True</show_titles> <show_titles>True</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type> <shadow_type>GTK_SHADOW_IN</shadow_type>

View File

@ -875,9 +875,9 @@ def save_file(filename):
except OSError, msg: except OSError, msg:
GnomeErrorDialog(_("Could not create %s") % filename + "\n" + str(msg)) GnomeErrorDialog(_("Could not create %s") % filename + "\n" + str(msg))
return return
except: # except:
GnomeErrorDialog(_("Could not create %s") % filename) # GnomeErrorDialog(_("Could not create %s") % filename)
return # return
database.setSavePath(old_file) database.setSavePath(old_file)
utils.clearModified() utils.clearModified()
@ -1954,11 +1954,11 @@ def load_tree_values(person,index,max,pv_text,tip):
bdate = person.getBirth().getDate() bdate = person.getBirth().getDate()
ddate = person.getDeath().getDate() ddate = person.getDeath().getDate()
if bdate and ddate: 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: elif bdate and not ddate:
text = msg + "\nb. " + bdate text = "%s\nb. %s" % (msg, bdate)
elif not bdate and ddate: elif not bdate and ddate:
text = msg + "\nd. " + ddate text = "%s\nb. %s" % (msg, ddate)
else: else:
text = msg text = msg
tip[index] = text tip[index] = text