fixed cStringIO uses

This commit is contained in:
Emmanuel Viennet 2021-07-11 23:02:35 +02:00
parent 585e80e523
commit 49e95d0085
5 changed files with 21 additions and 12 deletions

View File

@ -43,9 +43,13 @@ La préférence 'bul_pdf_class_name' est obsolete (inutilisée).
"""
import time
import cStringIO
import collections
import traceback
try:
from io import StringIO # for Python 3
except ImportError:
from cStringIO import StringIO # for Python 2
import reportlab
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Frame, PageBreak
from reportlab.platypus import Table, TableStyle, Image, KeepInFrame
@ -215,7 +219,7 @@ class BulletinGenerator(object):
else:
# Generation du document PDF
sem = sco_formsemestre.get_formsemestre(self.context, formsemestre_id)
report = cStringIO.StringIO() # in-memory document, no disk file
report = StringIO.StringIO() # in-memory document, no disk file
document = sco_pdf.BaseDocTemplate(report)
document.addPageTemplates(
sco_pdf.ScolarsPageTemplate(

View File

@ -54,8 +54,11 @@ import time
import traceback
import re
import os
import cStringIO
try:
from io import StringIO # for Python 3
except ImportError:
from cStringIO import StringIO # for Python 2
from reportlab.platypus.doctemplate import PageTemplate, BaseDocTemplate
from app.scodoc import VERSION
@ -89,7 +92,7 @@ def pdfassemblebulletins(
sco_preferences.get_preference(context, "bottom_margin", formsemestre_id),
)
report = cStringIO.StringIO() # in-memory document, no disk file
report = StringIO.StringIO() # in-memory document, no disk file
document = BaseDocTemplate(report)
document.addPageTemplates(
sco_pdf.ScolarsPageTemplate(

View File

@ -36,7 +36,6 @@ Optimisation possible:
import time
import collections
import re
import sets
import operator
import xml.dom.minidom
@ -1274,7 +1273,7 @@ def groups_auto_repartition(context, partition_id=None, REQUEST=None):
) # > identdict
identdict = nt.identdict
# build: { civilite : liste etudids trie par niveau croissant }
civilites = sets.Set([x["civilite"] for x in identdict.values()])
civilites = set([x["civilite"] for x in identdict.values()])
listes = {}
for civilite in civilites:
listes[civilite] = [

View File

@ -314,7 +314,7 @@ def pdf_basic_page(
adding a title if specified.
"""
StyleSheet = styles.getSampleStyleSheet()
report = cStringIO.StringIO() # in-memory document, no disk file
report = StringIO.StringIO() # in-memory document, no disk file
document = BaseDocTemplate(report)
document.addPageTemplates(
ScolarsPageTemplate(

View File

@ -28,9 +28,12 @@
"""Edition des PV de jury
"""
import os
import types
import re
import cStringIO
try:
from io import StringIO # for Python 3
except ImportError:
from cStringIO import StringIO # for Python 2
import reportlab
from reportlab.lib.units import cm, mm
from reportlab.lib.enums import TA_LEFT, TA_RIGHT, TA_CENTER, TA_JUSTIFY
@ -387,7 +390,7 @@ def pdf_lettres_individuelles(
)
# ----- Build PDF
report = cStringIO.StringIO() # in-memory document, no disk file
report = StringIO.StringIO() # in-memory document, no disk file
document = BaseDocTemplate(report)
document.addPageTemplates(
CourrierIndividuelTemplate(
@ -587,7 +590,7 @@ def _make_signature_image(signature, leftindent, formsemestre_id, context=None):
# cree une image PIL pour avoir la taille (W,H)
from PIL import Image as PILImage
f = cStringIO.StringIO(signature)
f = StringIO.StringIO(signature)
im = PILImage.open(f)
width, height = im.size
pdfheight = (
@ -671,7 +674,7 @@ def pvjury_pdf(
)
# ----- Build PDF
report = cStringIO.StringIO() # in-memory document, no disk file
report = StringIO.StringIO() # in-memory document, no disk file
document = BaseDocTemplate(report)
document.pagesize = landscape(A4)
document.addPageTemplates(