From: Stefan Pluecken Date: Thu, 19 Jan 2006 01:10:29 +0000 (+0000) Subject: saving the timers with dom is very very slow (12 timers take 5 seconds to save) so... X-Git-Tag: 2.6.0~4371 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/d76847392ff5cd26bc154f6c135310644c5c1d08 saving the timers with dom is very very slow (12 timers take 5 seconds to save) so as a workaround we don't use a xml parser to save the timers.xml file --- diff --git a/RecordTimer.py b/RecordTimer.py index e375c9f2..8f6999c9 100644 --- a/RecordTimer.py +++ b/RecordTimer.py @@ -219,43 +219,78 @@ class RecordTimer(timer.Timer): self.record(createTimer(timer)) def saveTimer(self): - doc = xml.dom.minidom.Document() - root_element = doc.createElement('timers') - doc.appendChild(root_element) - root_element.appendChild(doc.createTextNode("\n")) + #doc = xml.dom.minidom.Document() + #root_element = doc.createElement('timers') + #doc.appendChild(root_element) + #root_element.appendChild(doc.createTextNode("\n")) - for timer in self.timer_list + self.processed_timers: + #for timer in self.timer_list + self.processed_timers: # some timers (instant records) don't want to be saved. # skip them - if timer.dontSave: - continue - t = doc.createTextNode("\t") - root_element.appendChild(t) - t = doc.createElement('timer') - t.setAttribute("begin", str(int(timer.begin))) - t.setAttribute("end", str(int(timer.end))) - t.setAttribute("serviceref", str(timer.service_ref)) - t.setAttribute("repeated", str(timer.repeated)) - t.setAttribute("name", timer.name) - t.setAttribute("description", timer.description) - t.setAttribute("eit", str(timer.eit)) + #if timer.dontSave: + #continue + #t = doc.createTextNode("\t") + #root_element.appendChild(t) + #t = doc.createElement('timer') + #t.setAttribute("begin", str(int(timer.begin))) + #t.setAttribute("end", str(int(timer.end))) + #t.setAttribute("serviceref", str(timer.service_ref)) + #t.setAttribute("repeated", str(timer.repeated)) + #t.setAttribute("name", timer.name) + #t.setAttribute("description", timer.description) + #t.setAttribute("eit", str(timer.eit)) + + #for time, code, msg in timer.log_entries: + #t.appendChild(doc.createTextNode("\t\t")) + #l = doc.createElement('log') + #l.setAttribute("time", str(time)) + #l.setAttribute("code", str(code)) + #l.appendChild(doc.createTextNode(msg)) + #t.appendChild(l) + #t.appendChild(doc.createTextNode("\n")) + + #root_element.appendChild(t) + #t = doc.createTextNode("\n") + #root_element.appendChild(t) + + + #file = open(self.Filename, "w") + #doc.writexml(file) + #file.write("\n") + #file.close() + + list = [] + + list.append('\n') + list.append('\n') + + for timer in self.timer_list + self.processed_timers: + list.append('\n') for time, code, msg in timer.log_entries: - t.appendChild(doc.createTextNode("\t\t")) - l = doc.createElement('log') - l.setAttribute("time", str(time)) - l.setAttribute("code", str(code)) - l.appendChild(doc.createTextNode(msg)) - t.appendChild(l) - t.appendChild(doc.createTextNode("\n")) + list.append('') + list.append(str(msg)) + list.append('\n') + + + list.append('\n') - root_element.appendChild(t) - t = doc.createTextNode("\n") - root_element.appendChild(t) + list.append('\n') file = open(self.Filename, "w") - doc.writexml(file) - file.write("\n") + for x in list: + file.write(x) file.close() def record(self, entry):