py_ext/PythonFileCTNMixin.py
changeset 1330 96b242e4c59d
parent 1315 ff14a66bbd12
child 1436 e15ca67197b9
child 1473 23045c351012
equal deleted inserted replaced
1328:a2f2981df9b0 1330:96b242e4c59d
    35                 'xmlns:xhtml="http://www.w3.org/1999/xhtml"')
    35                 'xmlns:xhtml="http://www.w3.org/1999/xhtml"')
    36             for cre, repl in [
    36             for cre, repl in [
    37                 (re.compile("(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["),
    37                 (re.compile("(?<!<xhtml:p>)(?:<!\[CDATA\[)"), "<xhtml:p><![CDATA["),
    38                 (re.compile("(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]:
    38                 (re.compile("(?:]]>)(?!</xhtml:p>)"), "]]></xhtml:p>")]:
    39                 pythonfile_xml = cre.sub(repl, pythonfile_xml)
    39                 pythonfile_xml = cre.sub(repl, pythonfile_xml)
    40             python_code = etree.fromstring(pythonfile_xml, PythonParser)
    40             
    41             
    41             try:
    42             self.CodeFile.globals.setanyText(python_code.getanyText())
    42                 python_code, error = PythonParser.LoadXMLString(pythonfile_xml)
    43             os.remove(filepath)
    43                 if error is None:    
    44             self.CreateCodeFileBuffer(False)
    44                     self.CodeFile.globals.setanyText(python_code.getanyText())
    45             self.OnCTNSave()
    45                     os.remove(filepath)
       
    46                     self.CreateCodeFileBuffer(False)
       
    47                     self.OnCTNSave()
       
    48             except Exception, exc:
       
    49                 error = unicode(exc)
       
    50             
       
    51             if error is not None:
       
    52                 self.GetCTRoot().logger.write_error(
       
    53                     _("Couldn't import old %s file.") % CTNName)
    46     
    54     
    47     def CodeFileName(self):
    55     def CodeFileName(self):
    48         return os.path.join(self.CTNPath(), "pyfile.xml")
    56         return os.path.join(self.CTNPath(), "pyfile.xml")
    49     
    57     
    50     def PythonFileName(self):
    58     def PythonFileName(self):