コード例 #1
0
 def process_text(node, new_node):
     if new_node.tag in ['story', 'tr', 'section']:
         new_node.attrib.clear()
     for child in utils._child_get(node, self):
         new_child = copy.deepcopy(child)
         new_node.append(new_child)
         if len(child):
             for n in new_child:
                 new_child.text = utils._process_text(self, child.text)
                 new_child.tail = utils._process_text(self, child.tail)
                 new_child.remove(n)
             process_text(child, new_child)
         else:
             if new_child.tag == 'img' and new_child.get('name'):
                 if _regex.findall(new_child.get('name')):
                     src = utils._process_text(self,
                                               new_child.get('name'))
                     if src:
                         new_child.set('src',
                                       'data:image/gif;base64,%s' % src)
                         output = cStringIO.StringIO(
                             base64.decodestring(src))
                         img = ImageReader(output)
                         (width, height) = img.getSize()
                         if not new_child.get('width'):
                             new_child.set('width', str(width))
                         if not new_child.get('height'):
                             new_child.set('height', str(height))
                     else:
                         new_child.getparent().remove(new_child)
             new_child.text = utils._process_text(self, child.text)
             new_child.tail = utils._process_text(self, child.tail)
コード例 #2
0
ファイル: html2html.py プロジェクト: Buyanbat/XacCRM
 def process_text(node,new_node):
     if new_node.tag in ['story','tr','section']:
         new_node.attrib.clear()
     for child in utils._child_get(node, self):
         new_child = copy.deepcopy(child)
         new_node.append(new_child)
         if len(child):
             for n in new_child:
                 new_child.text  = utils._process_text(self, child.text)
                 new_child.tail  = utils._process_text(self, child.tail)
                 new_child.remove(n)
             process_text(child, new_child)
         else:
             if new_child.tag=='img' and new_child.get('name'):
                 if _regex.findall(new_child.get('name')) :
                     src =  utils._process_text(self, new_child.get('name'))
                     if src :
                         new_child.set('src','data:image/gif;base64,%s'%src)
                         output = cStringIO.StringIO(base64.decodestring(src))
                         img = ImageReader(output)
                         (width,height) = img.getSize()
                         if not new_child.get('width'):
                             new_child.set('width',str(width))
                         if not new_child.get('height') :
                             new_child.set('height',str(height))
                     else :
                         new_child.getparent().remove(new_child)
             new_child.text  = utils._process_text(self, child.text)
             new_child.tail  = utils._process_text(self, child.tail)
コード例 #3
0
ファイル: odt2odt.py プロジェクト: lbiemans/docker
 def process_text(node, new_node):
     for child in utils._child_get(node, self):
         new_child = copy.deepcopy(child)
         new_node.append(new_child)
         if len(child):
             for n in new_child:
                 new_child.text = utils._process_text(self, child.text)
                 new_child.tail = utils._process_text(self, child.tail)
                 new_child.remove(n)
             process_text(child, new_child)
         else:
             new_child.text = utils._process_text(self, child.text)
             new_child.tail = utils._process_text(self, child.tail)
コード例 #4
0
ファイル: odt2odt.py プロジェクト: Buyanbat/XacCRM
 def process_text(node,new_node):
     for child in utils._child_get(node, self):
         new_child = copy.deepcopy(child)
         new_node.append(new_child)
         if len(child):
             for n in new_child:
                 new_child.text  = utils._process_text(self, child.text)
                 new_child.tail  = utils._process_text(self, child.tail)
                 new_child.remove(n)
             process_text(child, new_child)
         else:
             new_child.text  = utils._process_text(self, child.text)
             new_child.tail  = utils._process_text(self, child.tail)