This commit is contained in:
Gaetan Delannay 2014-06-23 16:48:32 +02:00
parent f8f3c0e865
commit f7eaed817e
2 changed files with 12 additions and 10 deletions

View file

@ -285,7 +285,7 @@ class MemoryBuffer(Buffer):
return res return res
def isMainElement(self, elem): def isMainElement(self, elem):
'''Is p_elem the main elemen within this buffer?''' '''Is p_elem the main element within this buffer?'''
mainElem = self.getMainElement() mainElem = self.getMainElement()
if not mainElem: return if not mainElem: return
if hasattr(mainElem, 'OD'): mainElem = mainElem.OD.elem if hasattr(mainElem, 'OD'): mainElem = mainElem.OD.elem

View file

@ -103,17 +103,17 @@ class Renderer:
finalizeFunction=None, overwriteExisting=False, finalizeFunction=None, overwriteExisting=False,
raiseOnError=False, imageResolver=None): raiseOnError=False, imageResolver=None):
'''This Python Open Document Renderer (PodRenderer) loads a document '''This Python Open Document Renderer (PodRenderer) loads a document
template (p_template) which is an ODT file with some elements written template (p_template) which is an ODT or ODS file with some elements
in Python. Based on this template and some Python objects defined in written in Python. Based on this template and some Python objects
p_context, the renderer generates an ODT file (p_result) that defined in p_context, the renderer generates an ODT file (p_result)
instantiates the p_template and fills it with objects from the that instantiates the p_template and fills it with objects from the
p_context. p_context.
- If p_result does not end with .odt, the Renderer will call - If p_result does not end with .odt or .ods, the Renderer will call
LibreOffice to perform a conversion. If p_forceOoCall is True, even LibreOffice to perform a conversion. If p_forceOoCall is True, even
if p_result ends with .odt, LibreOffice will be called, not for if p_result ends with .odt, LibreOffice will be called, not for
performing a conversion, but for updating some elements like indexes performing a conversion, but for updating some elements like indexes
(table of contents, etc) and sections containing links to externa (table of contents, etc) and sections containing links to external
files (which is the case, for example, if you use the default files (which is the case, for example, if you use the default
function "document"). function "document").
@ -168,7 +168,6 @@ class Renderer:
# ODT file (to dump in manifest.xml); values are original paths of # ODT file (to dump in manifest.xml); values are original paths of
# included images (used for avoiding to create multiple copies of a file # included images (used for avoiding to create multiple copies of a file
# which is imported several times). # which is imported several times).
# imported file).
self.fileNames = {} self.fileNames = {}
self.prepareFolders() self.prepareFolders()
# Unzip template # Unzip template
@ -179,8 +178,11 @@ class Renderer:
# intermediary subfolder(s) if needed. # intermediary subfolder(s) if needed.
fileName = None fileName = None
if zippedFile.endswith('/') or zippedFile.endswith(os.sep): if zippedFile.endswith('/') or zippedFile.endswith(os.sep):
# This is an empty folder. Create it nevertheless. # This is an empty folder. Create it nevertheless. If zippedFile
os.makedirs(os.path.join(self.unzipFolder, zippedFile)) # starts with a '/', os.path.join will consider it an absolute
# path and will throw away self.unzipFolder.
os.makedirs(os.path.join(self.unzipFolder,
zippedFile.lstrip('/')))
else: else:
fileName = os.path.basename(zippedFile) fileName = os.path.basename(zippedFile)
folderName = os.path.dirname(zippedFile) folderName = os.path.dirname(zippedFile)