[Erp5-report] r20361 - /erp5/trunk/products/ERP5OOo/OOoTemplate.py

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Apr 8 17:41:57 CEST 2008


Author: nicolas
Date: Tue Apr  8 17:41:57 2008
New Revision: 20361

URL: http://svn.erp5.org?rev=20361&view=rev
Log:
Modify regex to take arguments with prefix
remove obselete matching in regex with escaped entities

Modified:
    erp5/trunk/products/ERP5OOo/OOoTemplate.py

Modified: erp5/trunk/products/ERP5OOo/OOoTemplate.py
URL: http://svn.erp5.org/erp5/trunk/products/ERP5OOo/OOoTemplate.py?rev=20361&r1=20360&r2=20361&view=diff
==============================================================================
--- erp5/trunk/products/ERP5OOo/OOoTemplate.py (original)
+++ erp5/trunk/products/ERP5OOo/OOoTemplate.py Tue Apr  8 17:41:57 2008
@@ -240,8 +240,7 @@
 
   def renderIncludes(self, here, text, sub_document=None):
     attached_files_dict = {}
-    arguments_re = re.compile('(\w+)\s*=\s*"(.*?)"\s*',re.DOTALL)
-
+    arguments_re = re.compile('(\w+:?\w+)\s*=\s*"(.*?)"\s*',re.DOTALL)
     def getLengthInfos( opts_dict, opts_names ):
       ret = []
       for opt_name in opts_names:
@@ -257,10 +256,8 @@
 
     def replaceIncludes(match):
       tag_string = match.group(1)
-
       # Build a dictionary with tag parameters
-      options_dict = dict(arguments_re.findall(match.group(1)))
-
+      options_dict = dict(arguments_re.findall(tag_string))
       # Find the page template based on the path and remove path from dict
       document = self._resolvePath(options_dict['path'].encode())
       document_text = ZopePageTemplate.pt_render(document) # extra_context is missing
@@ -334,8 +331,8 @@
       parameter_list = []
       for k, v in options_dict.items():
         parameter_list.append('%s="%s"' % (k, v))
-      new_tag = '<draw:object draw:name="ERP5IncludedObject%d" xlink:href="./%s" %s/>' %\
-                 (actual_idx, dir_name.split('/')[-1], ' '.join(parameter_list))
+      new_tag = '<draw:object xlink:href="./%s" %s/>' %\
+                 (dir_name.split('/')[-1], ' '.join(parameter_list))
       return new_tag
 
     def replaceIncludesImg(match):
@@ -447,9 +444,8 @@
     # It's an equivalent to DOTALL option passing (but sub can't get options parameter)
     text = re.sub('<\s*office:include_img\s+(.*?)\s*/\s*>(?s)', replaceIncludesImg, text)
     text = re.sub('<\s*office:include\s+(.*?)\s*/\s*>(?s)', replaceIncludes, text)
-    text = re.sub('&lt;\s*office:include\s+(.*?)\s*/\s*&gt;(?s)', replaceIncludes, text)
+
     return (text, attached_files_dict)
-
   # Proxy method to PageTemplate
   def pt_render(self, source=0, extra_context={}):
     # Get request




More information about the Erp5-report mailing list