Пример #1
0
 def UpdateTask(self, taskName, updateKey, updateValue):
     searchResult = self.FindTask(taskName)
     if (searchResult):
         self.taskList.remove(searchResult)
         searchResultDict = searchResult.__dict__
         searchResultDict[updateKey.title()] = updateValue
         self.taskList.append(Task._toTask(searchResultDict))
         self.SaveTasks(self.fileName)
         return searchResult
     else:
         return None
Пример #2
0
 def LoadTasks(self, fileName):
     self.taskList = []
     try:
         with open(fileName) as readObj:
             for line in readObj:
                 taskLine = json.loads(line)
                 self.taskList.append(Task._toTask(taskLine))
             return self.taskList
     except IOError:
         print("The file does not exist. Creating a new file")
         with open(fileName, 'w') as writeObj:
             writeObj.write("")
             return []