diff --git a/gramps/src/GrampsParser.py b/gramps/src/GrampsParser.py
index dfc404383..497341485 100644
--- a/gramps/src/GrampsParser.py
+++ b/gramps/src/GrampsParser.py
@@ -86,6 +86,7 @@ class GrampsParser(handler.ContentHandler):
self.in_scomments = 0
self.db = database
self.base = base
+ self.photo = None
self.person = None
self.family = None
self.address = None
@@ -230,7 +231,9 @@ class GrampsParser(handler.ContentHandler):
self.attribute.setType(u2l(attrs["type"]))
else:
self.in_old_attr = 0
- if self.person:
+ if self.photo:
+ self.photo.addAttribute(self.attribute)
+ elif self.person:
self.person.addAttribute(self.attribute)
elif self.family:
self.family.addAttribute(self.attribute)
@@ -440,28 +443,31 @@ class GrampsParser(handler.ContentHandler):
#
#---------------------------------------------------------------------
def start_photo(self,attrs):
- photo = Photo()
+ self.photo = Photo()
for key in attrs.keys():
if key == "descrip" or key == "description":
- photo.setDescription(u2l(attrs[key]))
+ self.photo.setDescription(u2l(attrs[key]))
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)
+ self.photo.setPath("%s%s%s" % (self.base,os.sep,src))
+ self.photo.setPrivate(1)
else:
- photo.setPath(src)
- photo.setPrivate(0)
+ self.photo.setPath(src)
+ self.photo.setPrivate(0)
if self.family:
- self.family.addPhoto(photo)
+ self.family.addPhoto(self.photo)
elif self.source:
- self.source.addPhoto(photo)
+ self.source.addPhoto(self.photo)
elif self.person:
- self.person.addPhoto(photo)
+ self.person.addPhoto(self.photo)
elif self.placeobj:
- self.placeobj.addPhoto(photo)
+ self.placeobj.addPhoto(self.photo)
else:
- photo.addProperty(key,u2l(attrs[key]))
+ a = Attribute()
+ a.setType(key)
+ a.setValue(u2l(attrs[key]))
+ self.photo.addAttribute(a)
#---------------------------------------------------------------------
#
@@ -514,14 +520,12 @@ class GrampsParser(handler.ContentHandler):
def stop_address(self,tag):
self.address = None
- #---------------------------------------------------------------------
- #
- #
- #
- #---------------------------------------------------------------------
def stop_places(self,tag):
self.placeobj = None
+ def stop_photo(self,tag):
+ self.photo = None
+
def stop_placeobj(self,tag):
if self.placeobj.get_title() == "":
loc = self.placeobj.get_main_location()
@@ -951,7 +955,7 @@ class GrampsParser(handler.ContentHandler):
"parentin" : (start_parentin,None),
"people" : (start_people, stop_people),
"person" : (start_person, None),
- "img" : (start_photo, None),
+ "img" : (start_photo, stop_photo),
"place" : (start_place, stop_place),
"places" : (None, stop_places),
"placeobj" : (start_placeobj,stop_placeobj),
diff --git a/gramps/src/RelLib.py b/gramps/src/RelLib.py
index fdc985953..b4da08d6e 100644
--- a/gramps/src/RelLib.py
+++ b/gramps/src/RelLib.py
@@ -342,21 +342,17 @@ class Photo:
def __init__(self,source=None):
"""Create a new Photo object, copying from the source if provided"""
+ self.attrlist = []
if source:
self.path = source.path
self.desc = source.desc
self.private = source.private
- if self.proplist != None:
- self.proplist = {}
- for p in source.proplist.keys():
- self.proplist[p] = source.proplist[p]
- else:
- self.proplist = None
+ for attr in source.attrlist:
+ self.attrlist.append(Attribute(attr))
else:
self.path = ""
self.desc = ""
self.private = 0
- self.proplist = None
def setPath(self,path):
"""set the file path to the passed path"""
@@ -382,18 +378,15 @@ class Photo:
"""returns the description of the image"""
return self.desc
- def addProperty(self,key,value):
+ def addAttribute(self,attr):
"""Adds a propery to the Photo object. This is not used by gramps,
but provides a means for XML users to attach other properties to
the image"""
- if self.proplist == None:
- self.proplist = { key: value}
- else:
- self.proplist[key] = value;
+ self.attrlist.append(attr)
- def getPropertyList(self):
+ def getAttributeList(self):
"""returns the property list associated with the image"""
- return self.proplist
+ return self.attrlist
class Attribute(DataObj):
"""Provides a simple key/value pair for describing properties. Used
diff --git a/gramps/src/WriteXML.py b/gramps/src/WriteXML.py
index 3055a3713..60965b9e6 100644
--- a/gramps/src/WriteXML.py
+++ b/gramps/src/WriteXML.py
@@ -268,18 +268,19 @@ def dump_location(g,loc):
g.write('/>\n')
-def write_attribute_list(g, list):
+def write_attribute_list(g, list, indent=3):
+ sp = ' ' * indent
for attr in list:
- if len(attr.getSourceRef()) > 0 or attr.getNote():
- g.write(' \n' % conf_priv(attr))
+ if len(attr.getSourceRefList()) > 0 or attr.getNote():
+ g.write('%s\n' % (sp,conf_priv(attr)))
write_line(g,"attr_type",attr.getType(),4)
write_line(g,"attr_value",attr.getValue(),4)
for s in attr.getSourceRefList():
dump_source_ref(g,s,index+1)
writeNote(g,"note",attr.getNote(),4)
- g.write(' \n')
+ g.write('%s\n' % sp)
else:
- g.write(' ' % attr.getType())
+ g.write('%s' % (sp,attr.getType()))
g.write(fix(attr.getValue()))
g.write('\n')
@@ -296,11 +297,13 @@ def write_photo_list(g,list):
path = path[l+1:]
g.write(' \n")
+ proplist = photo.getAttributeList()
+ if len(proplist) == 0:
+ g.write("/>\n")
+ else:
+ g.write(">\n")
+ write_attribute_list(g,proplist,4)
+ g.write(' \n')
def write_url_list(g, list):