Esempio n. 1
0
 def LoadXml(self, filename):
     ''' Load a list of errors from XML
     
     .. warning:: Describe XML format here'''
     q = open(filename, "r")
     dom = xml.dom.minidom.parse(q)
     dom.normalize()
     self.errors = []
     for node in dom.childNodes:
         if node.tagName == "errors":
             for error in node.childNodes:
                 # TODO: default values
                 currentError = {"time":0, "programmer":0, "severity":0, "item":0}
                 for attr in error.childNodes:
                     if attr.nodeName == "time":
                         for k in attr.childNodes:
                             currentError["time"] = int(k.nodeValue)
                     elif attr.nodeName == "programmer":
                         for k in attr.childNodes:
                             currentError["programmer"] = k.nodeValue
                     elif attr.nodeName == "severity":
                         for k in attr.childNodes:
                             currentError["severity"] = k.nodeValue
                     elif attr.nodeName == "item":
                         for k in attr.childNodes:
                             currentError["item"] = k.nodeValue   
                 if currentError != {}:
                     e = Error(time=currentError["time"], programmer=currentError["programmer"],
                               severity=currentError["severity"], item=currentError["item"])
                     self.errors.append(e)                         
     q.close()
     self.CalculateErrorTimes()
Esempio n. 2
0
 def AddError(self, t, p, s, i):
     ''' Add a single new error.
     
     :param t: Time
     :param p: Programmer
     :param s: Severity
     :param i: Item'''
     e = Error(t, p, s, i)
     self.errors.append(e)
     self.CalculateErrorTimes()