[IMP] made rml2pdf independant
bzr revid: fp@tinyerp.com-20100301184204-84sq3n5dqvxtpdvh
This commit is contained in:
parent
8137150354
commit
4e2afb8853
|
@ -40,18 +40,16 @@ import re
|
|||
import reportlab
|
||||
from lxml import etree
|
||||
import copy
|
||||
import tools
|
||||
import locale
|
||||
import netsvc
|
||||
import traceback, sys
|
||||
|
||||
_regex = re.compile('\[\[(.+?)\]\]')
|
||||
|
||||
def str2xml(s):
|
||||
return s.replace('&', '&').replace('<', '<').replace('>', '>')
|
||||
return (s or '').replace('&', '&').replace('<', '<').replace('>', '>')
|
||||
|
||||
def xml2str(s):
|
||||
return s.replace('&','&').replace('<','<').replace('>','>')
|
||||
return (s or '').replace('&','&').replace('<','<').replace('>','>')
|
||||
|
||||
def _child_get(node, self=None, tagname=None):
|
||||
for n in node:
|
||||
|
@ -106,25 +104,24 @@ def _process_text(self, txt):
|
|||
sps = _regex.split(txt)
|
||||
while sps:
|
||||
# This is a simple text to translate
|
||||
result += tools.ustr(self.localcontext.get('translate', lambda x:x)(sps.pop(0)))
|
||||
result += unicode(self.localcontext.get('translate', lambda x:x)(sps.pop(0)))
|
||||
if sps:
|
||||
try:
|
||||
expr = sps.pop(0)
|
||||
txt = eval(expr,self.localcontext)
|
||||
if txt and (isinstance(txt, unicode) or isinstance(txt, str)):
|
||||
txt = tools.ustr(self.localcontext.get('translate', lambda x:x)(txt))
|
||||
txt = unicode(self.localcontext.get('translate', lambda x:x)(txt))
|
||||
except Exception,e:
|
||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
netsvc.Logger().notifyChannel('report', netsvc.LOG_ERROR,'report :\n%s\n%s\nexpr: %s' % (tb_s, str(e),expr.encode('utf-8')))
|
||||
if type(txt)==type('') or type(txt)==type(u''):
|
||||
txt2 = str2xml(txt)
|
||||
result += tools.ustr(txt2)
|
||||
result += unicode(txt2)
|
||||
elif (txt is not None) and (txt is not False):
|
||||
result += tools.ustr(txt)
|
||||
result += unicode(txt)
|
||||
return result
|
||||
|
||||
def text_get(node):
|
||||
return ''.join([tools.ustr(n.text) for n in node])
|
||||
return ''.join([unicode(n.text) for n in node])
|
||||
|
||||
units = [
|
||||
(re.compile('^(-?[0-9\.]+)\s*in$'), reportlab.lib.units.inch),
|
||||
|
|
Loading…
Reference in New Issue