buildframework/helium/sf/python/pythoncore/lib/log2xml.py
changeset 628 7c4a911dc066
parent 588 c7c26511138f
child 645 b8d81fa19e7d
equal deleted inserted replaced
588:c7c26511138f 628:7c4a911dc066
   121     result = ""
   121     result = ""
   122     for char in list(text):
   122     for char in list(text):
   123         v_char = ord(char)
   123         v_char = ord(char)
   124         if v_char == 0x9 or v_char == 0xa or v_char == 0xd:
   124         if v_char == 0x9 or v_char == 0xa or v_char == 0xd:
   125             result += char
   125             result += char
   126         elif v_char>=0x20 and v_char <= 0xd7ff:
   126         elif v_char >= 0x20 and v_char <= 0xd7ff:
   127             result += char
   127             result += char
   128         elif v_char>=0xe000 and v_char <= 0xfffd:
   128         elif v_char >= 0xe000 and v_char <= 0xfffd:
   129             result += char
   129             result += char
   130         elif v_char>=0x10000 and v_char <= 0x10ffff:
   130         elif v_char >= 0x10000 and v_char <= 0x10ffff:
   131             result += char
   131             result += char
   132         else:
   132         else:
   133             result += " " 
   133             result += " " 
   134     return result
   134     return result
   135 
   135 
   328     file_object.close()
   328     file_object.close()
   329 
   329 
   330 class ContentWriter(ContentHandler):
   330 class ContentWriter(ContentHandler):
   331     """ SAX Content writer. Parse and write an XML file. """
   331     """ SAX Content writer. Parse and write an XML file. """
   332     def __init__(self, op_sys, indent=""):
   332     def __init__(self, op_sys, indent=""):
       
   333         ContentHandler.__init__(self)
   333         self.os = op_sys
   334         self.os = op_sys
   334         self.indent = indent
   335         self.indent = indent
   335         self.__content = u""
   336         self.__content = u""
   336     
   337     
   337     def startElement(self, name, attrs):
   338     def startElement(self, name, attrs):
   338         """start Element"""
   339         """start Element"""
   339         self.os.write(self.indent + "<" + name)
   340         self.os.write(self.indent + "<" + name)
   340         if attrs.getLength() > 0:
   341         if attrs.getLength() > 0:
   341             self.os.write(" ")
   342             self.os.write(" ")
   342         self.os.write(" ".join(map(lambda x: "%s=\"%s\"" % (x, attrs.getValue(x)), attrs.getNames())))
   343         self.os.write(" ".join(["%s=\"%s\"" % (x, attrs.getValue(x)) for x in attrs.getNames()]))
   343         self.os.write(">\n")
   344         self.os.write(">\n")
   344         self.indent += "\t"
   345         self.indent += "\t"
   345         self.__content = ""
   346         self.__content = ""
   346     
   347     
   347     def endElement(self, name):
   348     def endElement(self, name):
   383     
   384     
   384     outfile = codecs.open(summary + ".tmp", 'w', "utf8")
   385     outfile = codecs.open(summary + ".tmp", 'w', "utf8")
   385     parser = make_parser()
   386     parser = make_parser()
   386     parser.setContentHandler(AppendSummary(outfile, xmllog))
   387     parser.setContentHandler(AppendSummary(outfile, xmllog))
   387     
   388     
   388     input = open(summary, 'r')
   389     input_ = open(summary, 'r')
   389     parser.parse(input)
   390     parser.parse(input_)
   390     input.close()
   391     input_.close()
   391     outfile.close()
   392     outfile.close()
   392     # Updating the summary file.
   393     # Updating the summary file.
   393     os.unlink(summary)
   394     os.unlink(summary)
   394     os.rename(summary + ".tmp", summary)
   395     os.rename(summary + ".tmp", summary)
   395     
   396     
   396 
   397 
   397 def symbian_log_header(output, config, command, dir):
   398 def symbian_log_header(output, config, command, dir_):
   398     """symbian log header"""
   399     """symbian log header"""
   399     output.log("===-------------------------------------------------")
   400     output.log("===-------------------------------------------------")
   400     output.log("=== %s" % config)
   401     output.log("=== %s" % config)
   401     output.log("===-------------------------------------------------")
   402     output.log("===-------------------------------------------------")
   402     output.log("=== %s started %s" % (config, datetime.datetime.now().ctime()))
   403     output.log("=== %s started %s" % (config, datetime.datetime.now().ctime()))
   403     output.log("=== %s == %s" % (config, dir))
   404     output.log("=== %s == %s" % (config, dir_))
   404     output.log("-- %s" % command)
   405     output.log("-- %s" % command)
   405     output.log("++ Started at %s" % datetime.datetime.now().ctime())
   406     output.log("++ Started at %s" % datetime.datetime.now().ctime())
   406     output.log("+++ HiRes Start %f" % time.time())
   407     output.log("+++ HiRes Start %f" % time.time())
   407     output.log("Chdir %s" % dir)
   408     output.log("Chdir %s" % dir_)
   408 
   409 
   409 
   410 
   410 def symbian_log_footer(output):
   411 def symbian_log_footer(output):
   411     """symbian log footer"""
   412     """symbian log footer"""
   412     output.log("+++ HiRes End %f" % time.time())
   413     output.log("+++ HiRes End %f" % time.time())