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 removeLog(self, l: Log): dailyLog = self.getDailyLog(l.getDay(), l.getMonth(), l.getYear()) dailyLog.removeLog(l)