6282: Can't create text reports with RTF output format in python 3.3

svn: r20997
This commit is contained in:
Benny Malengier 2013-01-05 12:08:07 +00:00
parent a7a82a6947
commit 565638fed8
3 changed files with 22 additions and 4 deletions

3
README
View File

@ -38,6 +38,9 @@ The following packages are optional
enchant. A version of gtkspell with gobject introspection enchant. A version of gtkspell with gobject introspection
is needed, so minimally version 3.0.0 is needed, so minimally version 3.0.0
PIL Python Image Library is needed to convert non jpg images to
jpg so as to include them in LaTeX output
ttf-freefont More font support in the reports ttf-freefont More font support in the reports
gir-webkit GObject introspection data of WebKit is required for the gir-webkit GObject introspection data of WebKit is required for the

View File

@ -40,6 +40,8 @@
from gramps.gen.ggettext import gettext as _ from gramps.gen.ggettext import gettext as _
from bisect import bisect from bisect import bisect
import re, os, sys import re, os, sys
import logging
_LOG = logging.getLogger(".latexdoc")
#----------------------------------------------------------------------- - #----------------------------------------------------------------------- -
# #
@ -48,7 +50,14 @@ import re, os, sys
#------------------------------------------------------------------------ #------------------------------------------------------------------------
from gramps.gen.plug.docgen import BaseDoc, TextDoc, PAPER_LANDSCAPE, FONT_SANS_SERIF, URL_PATTERN from gramps.gen.plug.docgen import BaseDoc, TextDoc, PAPER_LANDSCAPE, FONT_SANS_SERIF, URL_PATTERN
from gramps.gen.plug.docbackend import DocBackend from gramps.gen.plug.docbackend import DocBackend
import Image HAVE_PIL = False
try:
from PIL import Image
HAVE_PIL = True
except:
_LOG.warning(
_('No PIL Image installed for your python version, cannot produce jpg '
'images from non-jpg images in LaTex Documents'))
_CLICKABLE = r'''\url{\1}''' _CLICKABLE = r'''\url{\1}'''
@ -1203,7 +1212,9 @@ class LaTeXDoc(BaseDoc, TextDoc):
outfile = os.path.splitext(infile)[0] outfile = os.path.splitext(infile)[0]
pictname = latexescape(os.path.split(outfile)[1]) pictname = latexescape(os.path.split(outfile)[1])
outfile = ''.join((outfile, '.jpg')) outfile = ''.join((outfile, '.jpg'))
if infile != outfile: outfile2 = ''.join((outfile, '.jpeg'))
outfile3 = ''.join((outfile, '.png'))
if HAVE_PIL and infile not in [outfile, outfile2, outfile3] :
try: try:
curr_img = Image.open(infile) curr_img = Image.open(infile)
curr_img.save(outfile) curr_img.save(outfile)
@ -1214,6 +1225,11 @@ class LaTeXDoc(BaseDoc, TextDoc):
self.emit(''.join(('%\n *** Error: cannot convert ', infile, self.emit(''.join(('%\n *** Error: cannot convert ', infile,
'\n *** to ', outfile, '\n *** to ', outfile,
'%\n'))) '%\n')))
elif not HAVE_PIL:
self.emit(''.join(('%\n *** Error: cannot convert ', infile,
'\n *** to ', outfile,
'PIL not installed %\n')))
if self.in_table: if self.in_table:
self.pict_in_table = True self.pict_in_table = True
@ -1222,7 +1238,6 @@ class LaTeXDoc(BaseDoc, TextDoc):
self.pict_width = x self.pict_width = x
self.pict_height = y self.pict_height = y
def write_text(self,text,mark=None,links=False): def write_text(self,text,mark=None,links=False):
"""Write the text to the file""" """Write the text to the file"""
if text == '\n': if text == '\n':

View File

@ -295,7 +295,7 @@ class RTFDoc(BaseDoc,TextDoc):
self.text += '}' self.text += '}'
def start_superscript(self): def start_superscript(self):
self.text += '{{\*\updnprop5801}\up10 ' self.text += '{{\\*\\updnprop5801}\\up10 '
def end_superscript(self): def end_superscript(self):
self.text += '}' self.text += '}'