@@ -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 ''
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user