Exemple #1
0
 def _iterateLines(self, message, lineHandler):
     clog = open(self.combatlogFilename, "r", self.bufferSize) 
     progress, finish = loadingMessage(message)
     for startOffset, logDate, endOffset in self.logOffsets:
         if startOffset > 0:
             clog.seek(startOffset)
             for line in clog:
                 progress(clog.tell()-self.firstOffset, self.lastOffset-self.firstOffset)
                 if line.startswith(logDate):
                     lineHandler(line)
                 else:
                     break
     finish()
     clog.close()
Exemple #2
0
 def _findOffsets(self, days):
     uniqueOffsets = sorted(uniq(days))
     logDates=[]
     progress, finish = loadingMessage("Finding Offsets")
     binSearch = BinarySearch(self.combatlogFilename)
     lastPos = 0
     for pos in range(len(uniqueOffsets)):
         offset = uniqueOffsets[pos]
         targetDate = datetime.date.today() + datetime.timedelta(days=offset)
         logDate = "%d/%d " % (targetDate.month,targetDate.day)
         logStartPos = binSearch.findOffset(logDate, lastPos, progress)
         logEndPos = binSearch.findLastOffset("\n"+logDate,logStartPos, progress)
         lastPos = logStartPos
         self.logOffsets.append((logStartPos,logDate, logEndPos))
         logDates.append(logDate[:-1])
     for startOffset, logDate, endOffset in self.logOffsets:
         if self.firstOffset < 0:
             if startOffset > 0:
                 self.firstOffset = startOffset
         if endOffset > 0:
             self.lastOffset = endOffset
     finish()
     normalMessage("Date(s)", logDates)