Example #1
0
File: core.py Project: Terrance/DoX
 def loadTasks(self, path=os.path.join(os.path.expanduser("~"), "DoX")):
     # empty/reset task lists (if previously loaded)
     self.tasks = []
     self.done = []
     # no DoX folder, create it
     if not os.path.exists(path):
         os.makedirs(path)
     tasksPath = os.path.join(path, "tasks.txt")
     # no tasks file, create it
     if not os.path.exists(tasksPath):
         open(tasksPath, "w").close()
     donePath = os.path.join(path, "done.txt")
     # no completed tasks file, create it
     if not os.path.exists(donePath):
         open(donePath, "w").close()
     configPath = os.path.join(path, "config.txt")
     # open tasks file
     tasksFile = open(tasksPath, "rb")
     count = 1
     # loop through file
     for line in tasksFile:
         # parse line into task object
         taskObj = task().parse(line.decode("utf-8"))
         # add to list
         if taskObj:
             self.tasks.append(taskObj)
             count += 1
     tasksFile.close()
     # open completed tasks file
     doneFile = open(donePath, "rb")
     count = 1
     # loop through file
     for line in doneFile:
         # parse line into task object
         taskObj = task().parse(line.decode("utf-8"))
         # add to list
         if taskObj:
             self.done.append(taskObj)
             count += 1
     doneFile.close()
     # set IDs
     self.fixIDs()
     return self
Example #2
0
 def loadTasks(self, path=os.path.join(os.path.expanduser("~"), "DoX")):
     # empty/reset task lists (if previously loaded)
     self.tasks = []
     self.done = []
     # no DoX folder, create it
     if not os.path.exists(path):
         os.makedirs(path)
     tasksPath = os.path.join(path, "tasks.txt")
     # no tasks file, create it
     if not os.path.exists(tasksPath):
         open(tasksPath, "w").close()
     donePath = os.path.join(path, "done.txt")
     # no completed tasks file, create it
     if not os.path.exists(donePath):
         open(donePath, "w").close()
     configPath = os.path.join(path, "config.txt")
     # open tasks file
     tasksFile = open(tasksPath, "rb")
     count = 1
     # loop through file
     for line in tasksFile:
         # parse line into task object
         taskObj = task().parse(line.decode("utf-8"))
         # add to list
         if taskObj:
             self.tasks.append(taskObj)
             count += 1
     tasksFile.close()
     # open completed tasks file
     doneFile = open(donePath, "rb")
     count = 1
     # loop through file
     for line in doneFile:
         # parse line into task object
         taskObj = task().parse(line.decode("utf-8"))
         # add to list
         if taskObj:
             self.done.append(taskObj)
             count += 1
     doneFile.close()
     # set IDs
     self.fixIDs()
     return self
Example #3
0
File: core.py Project: Terrance/DoX
 def addTask(self,
             title="",
             desc="",
             pri=0,
             due=None,
             repeat=None,
             tags=None):
     # create new task and store in list
     self.tasks.append(task(None, title, desc, pri, due, repeat, tags))
     # set IDs
     self.fixIDs()
     return self
Example #4
0
File: core.py Project: Terrance/DoX
 def addTaskFromStr(self, line):
     # use task class parser instead
     tasks.append(task().parse(line))
     return self
Example #5
0
 def addTaskFromStr(self, line):
     # use task class parser instead
     tasks.append(task().parse(line))
     return self
Example #6
0
 def addTask(self, title="", desc="", pri=0, due=None, repeat=None, tags=None):
     # create new task and store in list
     self.tasks.append(task(None, title, desc, pri, due, repeat, tags))
     # set IDs
     self.fixIDs()
     return self