diff options
| author | Fabien Pinckaers <fp@tinyerp.com> | 2010-03-01 19:42:04 +0100 |
|---|---|---|
| committer | Fabien Pinckaers <fp@tinyerp.com> | 2010-03-01 19:42:04 +0100 |
| commit | 4e2afb88532604fbc35048e5697b634f96cce6f0 (patch) | |
| tree | a81c46cf997ab670442ded82817365a3fd2129f9 /bin/report/render/rml2pdf/utils.py | |
| parent | 8137150354fc00924f8f69c3e23397c7d79bfecf (diff) | |
[IMP] made rml2pdf independant
bzr revid: fp@tinyerp.com-20100301184204-84sq3n5dqvxtpdvh
Diffstat (limited to 'bin/report/render/rml2pdf/utils.py')
| -rw-r--r-- | bin/report/render/rml2pdf/utils.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/bin/report/render/rml2pdf/utils.py b/bin/report/render/rml2pdf/utils.py index 3a7dc4035ca..80912e47acb 100644 --- a/bin/report/render/rml2pdf/utils.py +++ b/bin/report/render/rml2pdf/utils.py @@ -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), |
