fs_loader now accepts a file object as a possible value o media.
This commit is contained in:
parent
9d8d79110c
commit
2a0f00c2d5
1 changed files with 9 additions and 5 deletions
|
|
@ -345,6 +345,7 @@ class Renderer(object):
|
|||
extension = guess_extension(mime)
|
||||
|
||||
media_path = 'Pictures/%s%s' % (name, extension)
|
||||
media.seek(0)
|
||||
self.files[media_path] = media.read(-1)
|
||||
if hasattr(media, 'close'):
|
||||
media.close()
|
||||
|
|
@ -359,10 +360,12 @@ class Renderer(object):
|
|||
|
||||
def fs_loader(self, media, *args, **kwargs):
|
||||
"""Loads a file from the file system.
|
||||
:param media: relative or absolute path of file to load.
|
||||
:param media: A file object or a relative or absolute path of a file.
|
||||
:type media: unicode
|
||||
"""
|
||||
if path.isfile(media):
|
||||
if hasattr(media, 'seek') and hasattr(media, 'read'):
|
||||
return (media, 'image/jpeg')
|
||||
elif path.isfile(media):
|
||||
filename = media
|
||||
else:
|
||||
if not self.media_path:
|
||||
|
|
@ -420,6 +423,7 @@ class Renderer(object):
|
|||
image_node.setAttribute(k, v)
|
||||
|
||||
# Keep original image reference value
|
||||
if isinstance(self.template_images[key]['value'], basestring):
|
||||
frame.setAttribute('draw:name',
|
||||
self.template_images[key]['value'])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue