Fixed path stripping in WriteXML

svn: r474
This commit is contained in:
Don Allingham 2001-10-15 04:19:17 +00:00
parent f45b6818b6
commit 014ea4f3a1

View File

@ -34,6 +34,7 @@ except:
gzip_ok = 0 gzip_ok = 0
fileroot = "" fileroot = ""
strip_photo = 0
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -55,7 +56,7 @@ def sortById(first,second):
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
def fix(line): def fix(line):
l = string.strip(line) l = string.stripline)
l = string.replace(l,'&','&') l = string.replace(l,'&','&')
l = string.replace(l,'>','>') l = string.replace(l,'>','>')
l = string.replace(l,'<','&lt;') l = string.replace(l,'<','&lt;')
@ -336,10 +337,13 @@ def write_object(g,object):
id = object.getId() id = object.getId()
type = object.getMimeType() type = object.getMimeType()
path = object.getPath() path = object.getPath()
l = len(fileroot) if strip_photo:
if len(path) >= l: path = os.path.basename(path)
if fileroot == path[0:l]: else:
path = path[l+1:] l = len(fileroot)
if len(path) >= l:
if fileroot == path[0:l]:
path = path[l+1:]
g.write(' <object id="%s" src="%s" mime="%s"' % (id,path,type)) g.write(' <object id="%s" src="%s" mime="%s"' % (id,path,type))
g.write(' description="%s"' % fix(object.getDescription())) g.write(' description="%s"' % fix(object.getDescription()))
alist = object.getAttributeList() alist = object.getAttributeList()