Группа :: Офис
Пакет: kraft
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: port-to-python3.patch
Скачать
Скачать
diff --git a/kraft/tools/erml2pdf.py b/kraft/tools/erml2pdf.py
index b20a748..b9ac413 100644
--- a/kraft/tools/erml2pdf.py
+++ b/kraft/tools/erml2pdf.py
@@ -22,7 +22,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import sys
-import StringIO
+import io
import xml.dom.minidom
import copy
import subprocess
@@ -102,7 +102,7 @@ regex_h = re.compile('#([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA
def color_get(col_str):
global allcols
- if col_str in allcols.keys():
+ if col_str in list(allcols.keys()):
return allcols[col_str]
res = regex_t.search(col_str, 0)
if res:
@@ -331,7 +331,7 @@ class _rml_canvas(object):
flow.drawOn(self.canvas,infos['x'],infos['y'])
infos['height']-=h
else:
- raise ValueError, "Not enough space"
+ raise ValueError("Not enough space")
def _line_mode(self, node):
ljoin = {'round':1, 'mitered':0, 'bevelled':2}
@@ -351,10 +351,10 @@ class _rml_canvas(object):
self.canvas.setDash(node.getAttribute('dash').split(','))
def _image(self, node):
- import urllib
+ import urllib.request, urllib.parse, urllib.error
from reportlab.lib.utils import ImageReader
- u = urllib.urlopen(str(node.getAttribute('file')))
- s = StringIO.StringIO()
+ u = urllib.request.urlopen(str(node.getAttribute('file')))
+ s = io.StringIO()
s.write(u.read())
s.seek(0)
img = ImageReader(s)
@@ -582,7 +582,7 @@ class _rml_template(object):
if not node.hasAttribute('pageSize'):
pageSize = (unit_get('21cm'), unit_get('29.7cm'))
else:
- ps = map(lambda x:x.strip(), node.getAttribute('pageSize').replace(')', '').replace('(', '').split(','))
+ ps = [x.strip() for x in node.getAttribute('pageSize').replace(')', '').replace('(', '').split(',')]
pageSize = ( unit_get(ps[0]),unit_get(ps[1]) )
cm = reportlab.lib.units.cm
self.doc_tmpl = platypus.BaseDocTemplate(out, pagesize=pageSize, **attr_get(node, ['leftMargin','rightMargin','topMargin','bottomMargin'], {'allowSplitting':'int','showBoundary':'bool','title':'str','author':'str'}))
@@ -651,7 +651,7 @@ class PdfWatermark:
outputStream.close()
return self.outputFile
else:
- stringIO = StringIO.StringIO();
+ stringIO = io.StringIO();
outputPdf.write( stringIO )
return stringIO.getvalue()
@@ -664,34 +664,34 @@ def parseString(data, fout=None):
fp.close()
return fout
else:
- fp = StringIO.StringIO()
+ fp = io.StringIO()
r.render(fp)
return fp.getvalue()
def erml2pdf_help():
- print 'Usage: erml2pdf [options] input.rml > output.pdf'
- print ''
- print 'Tool to render a file of the xml based markup language RML to PDF'
- print 'with option to merge another PDF file as watermark.'
- print ''
- print 'Options:'
- print '-o, --output <file> output file, instead of standard out'
- print '-m, --watermark-mode <mode> set the watermark mode with '
- print ' 0 = no watermark (default)'
- print ' 1 = watermark on first page'
- print ' 2 = watermark on all pages'
- print ' Note: a watermark file must be specified for 1, 2'
- print '-w, --watermark-file <file> watermark file, the first page is used.'
- print ''
+ print('Usage: erml2pdf [options] input.rml > output.pdf')
+ print('')
+ print('Tool to render a file of the xml based markup language RML to PDF')
+ print('with option to merge another PDF file as watermark.')
+ print('')
+ print('Options:')
+ print('-o, --output <file> output file, instead of standard out')
+ print('-m, --watermark-mode <mode> set the watermark mode with ')
+ print(' 0 = no watermark (default)')
+ print(' 1 = watermark on first page')
+ print(' 2 = watermark on all pages')
+ print(' Note: a watermark file must be specified for 1, 2')
+ print('-w, --watermark-file <file> watermark file, the first page is used.')
+ print('')
sys.exit(0)
if __name__=="__main__":
try:
opts, args = getopt.getopt(sys.argv[1:], "ho:w:m:", ["help", "output=", "watermark-file=", "watermark-mode="])
- except getopt.GetoptError, err:
+ except getopt.GetoptError as err:
# print help information and exit:
- print str(err) # will print something like "option -a not recognized"
+ print(str(err)) # will print something like "option -a not recognized"
erml2pdf_help()
sys.exit(2)
output = None
@@ -724,7 +724,7 @@ if __name__=="__main__":
# print "############ Watermark-Mode: " + watermarkMode
if watermarkMode != Mark.NOTHING:
wm = PdfWatermark()
- pdfStringFile = StringIO.StringIO()
+ pdfStringFile = io.StringIO()
pdfStringFile.write( pdf )
pdf = wm.watermark( pdfStringFile, watermarkFile, watermarkMode )
@@ -734,4 +734,4 @@ if __name__=="__main__":
outfile.write( pdf )
outfile.close()
else:
- print pdf
+ print(pdf)
--
2.25.1