diff options
| author | hda (Tiny) <hda@tinyerp.com> | 2009-12-08 15:42:46 +0530 |
|---|---|---|
| committer | hda (Tiny) <hda@tinyerp.com> | 2009-12-08 15:42:46 +0530 |
| commit | 24cd74becf6df66c71cdafc9f8a41ffdde903aec (patch) | |
| tree | cf195d12fdbdbeadd6de930c93e54b01fa959a23 /bin/report/render | |
| parent | a481bfb190667cd2fcb6335adf533afe6e1c8e2d (diff) | |
| parent | 474af4cd6e6f00759589c4bee9cebf9d7d26b0d8 (diff) | |
Merge
bzr revid: hda@tinyerp.com-20091208101246-5ave2zzgzsjqf0m8
Diffstat (limited to 'bin/report/render')
| -rw-r--r-- | bin/report/render/html2html/html2html.py | 2 | ||||
| -rw-r--r-- | bin/report/render/rml2html/rml2html.py | 10 | ||||
| -rw-r--r-- | bin/report/render/rml2pdf/trml2pdf.py | 7 | ||||
| -rw-r--r-- | bin/report/render/rml2pdf/utils.py | 14 |
4 files changed, 14 insertions, 19 deletions
diff --git a/bin/report/render/html2html/html2html.py b/bin/report/render/html2html/html2html.py index fa07e9b4726..9f81e26d4f2 100644 --- a/bin/report/render/html2html/html2html.py +++ b/bin/report/render/html2html/html2html.py @@ -75,7 +75,7 @@ class html2html(object): return self._node def url_modify(self,root): - for n in root.getchildren(): + for n in root: if (n.text.find('<a ')>=0 or n.text.find('<a')>=0) and n.text.find('href')>=0 and n.text.find('style')<=0 : node = (n.tag=='span' and n.getparent().tag=='u') and n.getparent().getparent() or ((n.tag=='span') and n.getparent()) or n style = node.get('color') and "style='color:%s; text-decoration: none;'"%node.get('color') or '' diff --git a/bin/report/render/rml2html/rml2html.py b/bin/report/render/rml2html/rml2html.py index 8f0197b32df..a3a14fc8aee 100644 --- a/bin/report/render/rml2html/rml2html.py +++ b/bin/report/render/rml2html/rml2html.py @@ -104,12 +104,10 @@ class _flowable(object): process(node,new_node) if new_node.get('colWidths',False): sizes = map(lambda x: utils.unit_get(x), new_node.get('colWidths').split(',')) - tr = etree.Element('tr') + tr = etree.SubElement(new_node, 'tr') for s in sizes: - td = etree.Element('td') - td.set("width", str(s)) - tr.append(td) - new_node.append(tr) + etree.SubElement(tr, 'td', width=str(s)) + return etree.tostring(new_node) def _tag_para(self, node): @@ -298,7 +296,7 @@ class _rml_template(object): posx = int(utils.unit_get(tmpl.get('x1'))) frames[(posy,posx,tmpl.get('id'))] = _rml_tmpl_frame(posx, utils.unit_get(tmpl.get('width'))) for tmpl in pt.findall('pageGraphics'): - for n in tmpl.getchildren(): + for n in tmpl: if n.tag == 'image': self.data = rc + utils._process_text(self, n.text) if n.tag in self._tags: diff --git a/bin/report/render/rml2pdf/trml2pdf.py b/bin/report/render/rml2pdf/trml2pdf.py index b3585254eb3..b7db9724781 100644 --- a/bin/report/render/rml2pdf/trml2pdf.py +++ b/bin/report/render/rml2pdf/trml2pdf.py @@ -88,7 +88,7 @@ class _rml_styles(object,): def _table_style_get(self, style_node): styles = [] - for node in style_node.getchildren(): + for node in style_node: start = utils.tuple_int_get(node, 'start', (0,0) ) stop = utils.tuple_int_get(node, 'stop', (-1,-1) ) if node.tag=='blockValign': @@ -166,7 +166,7 @@ class _rml_doc(object): def _textual_image(self, node): rc = '' - for n in node.getchildren(): + for n in node: rc +=( etree.tostring(n) or '') + n.tail return base64.decodestring(node.tostring()) @@ -749,7 +749,8 @@ class _rml_template(object): frame.lastFrame = True frames.append( frame ) try : - gr = pt.findall('pageGraphics') or pt.getchildren()[1].findall('pageGraphics') + gr = pt.findall('pageGraphics')\ + or pt[1].findall('pageGraphics') except : gr='' if len(gr): diff --git a/bin/report/render/rml2pdf/utils.py b/bin/report/render/rml2pdf/utils.py index abc421a0f2f..bbccd23bb28 100644 --- a/bin/report/render/rml2pdf/utils.py +++ b/bin/report/render/rml2pdf/utils.py @@ -56,7 +56,7 @@ def xml2str(s): def _child_get(node, self=None, tagname=None): for n in node: - if self and self.localcontext and n.get('rml_loop', False): + if self and self.localcontext and n.get('rml_loop'): oldctx = self.localcontext for ctx in eval(n.get('rml_loop'),{}, self.localcontext): @@ -80,12 +80,12 @@ def _child_get(node, self=None, tagname=None): yield n self.localcontext = oldctx continue - if self and self.localcontext and n.get('rml_except', False): + if self and self.localcontext and n.get('rml_except'): try: eval(n.get('rml_except'), {}, self.localcontext) except: continue - if self and self.localcontext and n.get('rml_tag', False): + if self and self.localcontext and n.get('rml_tag'): try: (tag,attr) = eval(n.get('rml_tag'),{}, self.localcontext) n2 = copy.deepcopy(n) @@ -125,10 +125,7 @@ def _process_text(self, txt): return result def text_get(node): - rc = '' - for node in node.getchildren(): - rc = rc + tools.ustr(node.text) - return rc + return ''.join([tools.ustr(n.text) for n in node]) units = [ (re.compile('^(-?[0-9\.]+)\s*in$'), reportlab.lib.units.inch), @@ -158,8 +155,7 @@ def unit_get(size): def tuple_int_get(node, attr_name, default=None): if not node.get(attr_name): return default - res = [int(x) for x in node.get(attr_name).split(',')] - return res + return map(int, node.get(attr_name).split(',')) def bool_get(value): return (str(value)=="1") or (value.lower()=='yes') |
