[IMP] Use cStringIO
bzr revid: stephane@tinyerp.com-20090105210240-nkg2vm08dwhz2xtq
This commit is contained in:
@@ -41,7 +41,7 @@ import release
|
||||
import re
|
||||
import base64
|
||||
from zipfile import PyZipFile, ZIP_DEFLATED
|
||||
import StringIO
|
||||
import cStringIO
|
||||
|
||||
logger = netsvc.Logger()
|
||||
|
||||
@@ -198,7 +198,7 @@ def get_module_as_zip(modulename, b64enc=True, src=True):
|
||||
if os.path.isfile(ap + '.zip'):
|
||||
val = file(ap + '.zip', 'rb').read()
|
||||
else:
|
||||
archname = StringIO.StringIO('wb')
|
||||
archname = cStringIO.StringIO('wb')
|
||||
archive = PyZipFile(archname, "w", ZIP_DEFLATED)
|
||||
archive.writepy(ap)
|
||||
_zippy(archive, ap, src=src)
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
import wizard
|
||||
import tools
|
||||
import base64
|
||||
import StringIO
|
||||
import cStringIO
|
||||
import csv
|
||||
import pooler
|
||||
from osv import fields,osv
|
||||
@@ -49,7 +49,7 @@ class wizard_export_lang(osv.osv_memory):
|
||||
this = self.browse(cr, uid, ids)[0]
|
||||
mods = map(lambda m: m.name, this.modules) or ['all']
|
||||
mods.sort()
|
||||
buf=StringIO.StringIO()
|
||||
buf=cStringIO.StringIO()
|
||||
tools.trans_export(this.lang, mods, buf, this.format, dbname=cr.dbname)
|
||||
if this.format == 'csv':
|
||||
this.advice = _("Save this document to a .CSV file and open it with your favourite spreadsheet software. The file encoding is UTF-8. You have to translate the latest column before reimporting it.")
|
||||
|
||||
@@ -28,7 +28,7 @@ import os
|
||||
import tools
|
||||
|
||||
import zipfile
|
||||
import StringIO
|
||||
import cStringIO
|
||||
import base64
|
||||
|
||||
finish_form ='''<?xml version="1.0"?>
|
||||
@@ -55,7 +55,7 @@ class move_module_wizard(wizard.interface):
|
||||
module_data = data['form']['module_file']
|
||||
|
||||
val =base64.decodestring(module_data)
|
||||
fp = StringIO.StringIO(val)
|
||||
fp = cStringIO.StringIO(val)
|
||||
fdata = zipfile.ZipFile(fp, 'r')
|
||||
fname = fdata.namelist()[0]
|
||||
module_name = os.path.split(fname)[0]
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
from osv import osv, fields
|
||||
import tools
|
||||
import pooler
|
||||
import StringIO
|
||||
import cStringIO
|
||||
|
||||
class update_translations(osv.osv_memory):
|
||||
def _get_languages(self, cr, uid, context):
|
||||
@@ -45,7 +45,7 @@ class update_translations(osv.osv_memory):
|
||||
def act_update(self, cr, uid, ids, context=None):
|
||||
this = self.browse(cr, uid, ids)[0]
|
||||
lang_name = self._get_lang_name(cr, uid, this.lang)
|
||||
buf=StringIO.StringIO()
|
||||
buf=cStringIO.StringIO()
|
||||
tools.trans_export(this.lang, ['all'], buf, 'csv', dbname=cr.dbname)
|
||||
tools.trans_load_data(cr.dbname, buf, 'csv', this.lang, lang_name=lang_name)
|
||||
buf.close()
|
||||
|
||||
@@ -20,7 +20,8 @@
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
import os, time
|
||||
import os
|
||||
import time
|
||||
import netsvc
|
||||
|
||||
import tools
|
||||
@@ -37,7 +38,7 @@ import libxml2
|
||||
import libxslt
|
||||
from pychart import *
|
||||
import misc
|
||||
import StringIO
|
||||
import cStringIO
|
||||
|
||||
class external_pdf(render.render):
|
||||
def __init__(self, pdf):
|
||||
@@ -358,7 +359,7 @@ class report_custom(report_int):
|
||||
|
||||
def _create_lines(self, cr, uid, ids, report, fields, results, context):
|
||||
service = netsvc.LocalService("object_proxy")
|
||||
pdf_string = StringIO.StringIO()
|
||||
pdf_string = cStringIO.StringIO()
|
||||
can = canvas.init(fname=pdf_string, format='pdf')
|
||||
|
||||
can.show(80,380,'/16/H'+report['title'])
|
||||
@@ -461,7 +462,7 @@ class report_custom(report_int):
|
||||
|
||||
def _create_bars(self, cr, uid, ids, report, fields, results, context):
|
||||
service = netsvc.LocalService("object_proxy")
|
||||
pdf_string = StringIO.StringIO()
|
||||
pdf_string = cStringIO.StringIO()
|
||||
can = canvas.init(fname=pdf_string, format='pdf')
|
||||
|
||||
can.show(80,380,'/16/H'+report['title'])
|
||||
@@ -558,7 +559,7 @@ class report_custom(report_int):
|
||||
return True
|
||||
|
||||
def _create_pie(self, cr, uid, ids, report, fields, results, context):
|
||||
pdf_string = StringIO.StringIO()
|
||||
pdf_string = cStringIO.StringIO()
|
||||
can = canvas.init(fname=pdf_string, format='pdf')
|
||||
ar = area.T(size=(350,350), legend=legend.T(),
|
||||
x_grid_style = None, y_grid_style = None)
|
||||
|
||||
@@ -162,9 +162,10 @@ class document(object):
|
||||
fname = str(datas['datas_fname'])
|
||||
ext = fname.split('.')[-1].lower()
|
||||
if ext in ('jpg','jpeg', 'png'):
|
||||
import base64, StringIO
|
||||
import base64
|
||||
import cStringIO
|
||||
dt = base64.decodestring(datas['datas'])
|
||||
fp = StringIO.StringIO(dt)
|
||||
fp = cStringIO.StringIO(dt)
|
||||
i = str(len(self.bin_datas))
|
||||
self.bin_datas[i] = fp
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
import sys
|
||||
import StringIO
|
||||
import cStringIO
|
||||
import xml.dom.minidom
|
||||
import copy
|
||||
|
||||
@@ -365,7 +365,7 @@ def parseString(data, fout=None):
|
||||
fp.close()
|
||||
return fout
|
||||
else:
|
||||
fp = StringIO.StringIO()
|
||||
fp = cStringIO.StringIO()
|
||||
r.render(fp)
|
||||
return fp.getvalue()
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
import sys
|
||||
import StringIO
|
||||
import cStringIO
|
||||
import xml.dom.minidom
|
||||
import copy
|
||||
|
||||
@@ -355,22 +355,22 @@ class _rml_canvas(object):
|
||||
|
||||
if node.hasAttribute('name'):
|
||||
image_data = self.images[node.getAttribute('name')]
|
||||
s = StringIO.StringIO(image_data)
|
||||
s = cStringIO.StringIO(image_data)
|
||||
else:
|
||||
import base64
|
||||
image_data = base64.decodestring(node.firstChild.nodeValue)
|
||||
if not image_data: return False
|
||||
s = StringIO.StringIO(image_data)
|
||||
s = cStringIO.StringIO(image_data)
|
||||
else:
|
||||
if node.getAttribute('file') in self.images:
|
||||
s = StringIO.StringIO(self.images[node.getAttribute('file')])
|
||||
s = cStringIO.StringIO(self.images[node.getAttribute('file')])
|
||||
else:
|
||||
try:
|
||||
u = urllib.urlopen(str(node.getAttribute('file')))
|
||||
s = StringIO.StringIO(u.read())
|
||||
s = cStringIO.StringIO(u.read())
|
||||
except:
|
||||
u = file(os.path.join(self.path,str(node.getAttribute('file'))), 'rb')
|
||||
s = StringIO.StringIO(u.read())
|
||||
s = cStringIO.StringIO(u.read())
|
||||
img = ImageReader(s)
|
||||
(sx,sy) = img.getSize()
|
||||
|
||||
@@ -639,7 +639,7 @@ class _rml_flowable(object):
|
||||
else:
|
||||
import base64
|
||||
image_data = base64.decodestring(node.firstChild.nodeValue)
|
||||
image = StringIO.StringIO(image_data)
|
||||
image = cStringIO.StringIO(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 +794,7 @@ def parseString(data, fout=None, images={}, path='.',title=None):
|
||||
fp.close()
|
||||
return fout
|
||||
else:
|
||||
fp = StringIO.StringIO()
|
||||
fp = cStringIO.StringIO()
|
||||
r.render(fp)
|
||||
return fp.getvalue()
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
import render
|
||||
|
||||
from StringIO import StringIO
|
||||
from cStringIO import StringIO
|
||||
import xml.dom.minidom
|
||||
|
||||
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
##############################################################################
|
||||
|
||||
from interface import report_rml
|
||||
import StringIO
|
||||
import cStringIO
|
||||
import base64
|
||||
import copy
|
||||
import ir
|
||||
@@ -618,7 +618,7 @@ class report_sxw(report_rml):
|
||||
|
||||
if report_type in ['sxw','odt'] and report_xml:
|
||||
context['parents'] = sxw_parents
|
||||
sxw_io = StringIO.StringIO(report_xml.report_sxw_content)
|
||||
sxw_io = cStringIO.StringIO(report_xml.report_sxw_content)
|
||||
sxw_z = zipfile.ZipFile(sxw_io, mode='r')
|
||||
rml = sxw_z.read('content.xml')
|
||||
meta = sxw_z.read('meta.xml')
|
||||
|
||||
@@ -105,7 +105,7 @@ class db(netsvc.Service):
|
||||
except Exception, e:
|
||||
serv.actions[id]['clean'] = False
|
||||
serv.actions[id]['exception'] = e
|
||||
from StringIO import StringIO
|
||||
from cStringIO import StringIO
|
||||
import traceback
|
||||
e_str = StringIO()
|
||||
traceback.print_exc(file=e_str)
|
||||
|
||||
@@ -20,8 +20,11 @@
|
||||
#
|
||||
##############################################################################
|
||||
import re
|
||||
import StringIO,xml.dom.minidom
|
||||
import osv,ir,pooler
|
||||
import cStringIO
|
||||
import xml.dom.minidom
|
||||
import osv
|
||||
import ir
|
||||
import pooler
|
||||
|
||||
import csv
|
||||
import os.path
|
||||
@@ -804,7 +807,7 @@ def convert_csv_import(cr, module, fname, csvcontent, idref=None, mode='init',
|
||||
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
|
||||
input = StringIO.StringIO(csvcontent)
|
||||
input = cStringIO.StringIO(csvcontent)
|
||||
reader = csv.reader(input, quotechar='"', delimiter=',')
|
||||
fields = reader.next()
|
||||
fname_partial = ""
|
||||
|
||||
+2
-2
@@ -224,10 +224,10 @@ def file_open(name, mode="r", subdir='addons', pathinfo=False):
|
||||
else:
|
||||
zipname = tail
|
||||
if zipfile.is_zipfile(head+'.zip'):
|
||||
import StringIO
|
||||
import cStringIO
|
||||
zfile = zipfile.ZipFile(head+'.zip')
|
||||
try:
|
||||
fo = StringIO.StringIO(zfile.read(os.path.join(
|
||||
fo = cStringIO.StringIO(zfile.read(os.path.join(
|
||||
os.path.basename(head), zipname).replace(
|
||||
os.sep, '/')))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user