def addLog(self, l: Log): # find the year if l.getYear() not in self._yearlyLogs: self._yearlyLogs[l.getYear()] = YearlyLog(l.getYear()) yearLog = self._yearlyLogs[l.getYear()] # find the month if l.getMonth() not in yearLog.getMonthlyLogs(): yearLog.getMonthlyLogs()[l.getMonth()] = MonthlyLog( l.getMonth(), l.getYear()) monthLog = yearLog.getMonthlyLogs()[l.getMonth()] # find the day if l.getDay() not in monthLog.getDailyLogs(): monthLog.getDailyLogs()[l.getDay()] = DailyLog( l.getDay(), l.getMonth(), l.getYear()) dailyLog = monthLog.getDailyLogs()[l.getDay()] # add dailyLog.addLog(l)
def setUp(self): self.logs = DailyLog('20210125') self.value = '{"error":"", "logs":[\
def getDailyLog(self, day, month, year): if day not in self.getMonthlyLog(month, year).getDailyLogs(): self.getMonthlyLog(month, year).getDailyLogs()[day] = DailyLog( day, month, year) return self.getMonthlyLog(month, year).getDailyLogs()[day]