[FIX] StringIO

bzr revid: stephane@tinyerp.com-20090109121820-vlxvuadud95x9jox
This commit is contained in:
Stephane Wirtel 2009-01-09 13:18:20 +01:00
parent 383c212c97
commit 80a7a66742
3 changed files with 15 additions and 12 deletions

View File

@ -28,7 +28,7 @@ import os
import tools
import zipfile
import cStringIO
from StringIO import StringIO
import base64
finish_form ='''<?xml version="1.0"?>
@ -55,7 +55,8 @@ class move_module_wizard(wizard.interface):
module_data = data['form']['module_file']
val =base64.decodestring(module_data)
fp = cStringIO.StringIO(val)
fp = StringIO()
fp.write(val)
fdata = zipfile.ZipFile(fp, 'r')
fname = fdata.namelist()[0]
module_name = os.path.split(fname)[0]

View File

@ -163,9 +163,10 @@ class document(object):
ext = fname.split('.')[-1].lower()
if ext in ('jpg','jpeg', 'png'):
import base64
import cStringIO
from StringIO import StringIO
dt = base64.decodestring(datas['datas'])
fp = cStringIO.StringIO(dt)
fp = StringIO()
fp.write(dt)
i = str(len(self.bin_datas))
self.bin_datas[i] = fp

View File

@ -40,7 +40,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import sys
import cStringIO
from StringIO import StringIO
import xml.dom.minidom
import copy
@ -351,26 +351,26 @@ class _rml_canvas(object):
import urllib
from reportlab.lib.utils import ImageReader
s = StringIO()
if not node.hasAttribute('file'):
if node.hasAttribute('name'):
image_data = self.images[node.getAttribute('name')]
s = cStringIO.StringIO(image_data)
s.write(image_data)
else:
import base64
image_data = base64.decodestring(node.firstChild.nodeValue)
if not image_data: return False
s = cStringIO.StringIO(image_data)
s.write(image_data)
else:
if node.getAttribute('file') in self.images:
s = cStringIO.StringIO(self.images[node.getAttribute('file')])
s.write(self.images[node.getAttribute('file')])
else:
try:
u = urllib.urlopen(str(node.getAttribute('file')))
s = cStringIO.StringIO(u.read())
except:
u = file(os.path.join(self.path,str(node.getAttribute('file'))), 'rb')
s = cStringIO.StringIO(u.read())
s.write(u.read())
img = ImageReader(s)
(sx,sy) = img.getSize()
@ -639,7 +639,8 @@ class _rml_flowable(object):
else:
import base64
image_data = base64.decodestring(node.firstChild.nodeValue)
image = cStringIO.StringIO(image_data)
image = StringIO()
image.write(image_data)
return platypus.Image(image, mask=(250,255,250,255,250,255), **(utils.attr_get(node, ['width','height'])))
else:
return platypus.Image(node.getAttribute('file'), mask=(250,255,250,255,250,255), **(utils.attr_get(node, ['width','height'])))
@ -794,7 +795,7 @@ def parseString(data, fout=None, images={}, path='.',title=None):
fp.close()
return fout
else:
fp = cStringIO.StringIO()
fp = StringIO()
r.render(fp)
return fp.getvalue()