From c009a3176a3ee805ca6d0b6948ec5e7a9d5d074a Mon Sep 17 00:00:00 2001 From: Maciej Krok Date: Sat, 8 Oct 2016 11:01:26 +0200 Subject: [PATCH] support for today added today to plist fixing due date name in plist --- thingspy/Project.py | 11 +++++++++-- thingspy/ToDo.py | 17 ++++++++++++++--- thingspy/sample.plist | 18 ++++++++++++++---- thingspy/things.py | 2 ++ 4 files changed, 39 insertions(+), 9 deletions(-) diff --git a/thingspy/Project.py b/thingspy/Project.py index ea4832c..947f273 100644 --- a/thingspy/Project.py +++ b/thingspy/Project.py @@ -23,8 +23,15 @@ class Project(ToDo): def makeAppleScript(self): ans = "\n" + ans += "\n" - ans += "set " + self.getMD5() + " to make new project \n" + + ans += "set " + self.getMD5() + " to make new project " + + if self.isToDay(): + ans += "at beginning of list \"Today\"" + + ans += "\n" ans += "set name of " + self.getMD5() + " to \"" + self.getName() + "\"\n" @@ -35,7 +42,7 @@ class Project(ToDo): ans += "set notes of " + self.getMD5() + " to \"" + self.getNotes() + "\"\n" if self.getDueDate() > 0: - ans += "set due date of " + self.getMD5() + " to (current date) + " + self.getDueDate() + " * days\n" + ans += "set due date of " + self.getMD5() + " to (current date) + " + str(self.getDueDate()) + " * days\n" tags = "" for tag in self.getTags(): diff --git a/thingspy/ToDo.py b/thingspy/ToDo.py index 4b0b56e..229508b 100644 --- a/thingspy/ToDo.py +++ b/thingspy/ToDo.py @@ -21,9 +21,14 @@ class ToDo: return self.plist["tags"] def getDueDate(self): - if "due date " not in self.plist: + if "due date" not in self.plist: return 0 - return self.plist["due date "] + return self.plist["due date"] + + def isToDay(self): + if "today" not in self.plist: + return False + return self.plist["today"] def getMD5(self): return self.md5 @@ -33,8 +38,14 @@ class ToDo: def makeAppleScript(self): ans = "\n" + ans += "\n" - ans += "set " + self.getMD5() +" to make new to do \n" + ans += "set " + self.getMD5() +" to make new to do " + + if self.isToDay(): + ans += "at beginning of list \"Today\"" + + ans += "\n" ans += "set name of " + self.getMD5() + " to \""+ self.getName() +"\"\n" diff --git a/thingspy/sample.plist b/thingspy/sample.plist index f3979fa..73e8d7a 100644 --- a/thingspy/sample.plist +++ b/thingspy/sample.plist @@ -7,8 +7,10 @@ name sample todos0 - due date + due date 5 + today + tags sampleTag4 @@ -35,6 +37,8 @@ Phasellus fringilla est sed congue mollis. Nullam cursus aliquam arcu quis tinci Duis at congue nisl. In pharetra vitae nibh at finibus. Aenean ullamcorper purus a ultrices consectetur. Duis sed ultricies sapien, pulvinar vestibulum libero. Donec id neque nec mi eleifend blandit at id libero. Nullam scelerisque massa quis ultrices tincidunt. Aenean condimentum rhoncus fringilla. due date 3 + today + tags sampleTag1 @@ -47,8 +51,10 @@ Duis at congue nisl. In pharetra vitae nibh at finibus. Aenean ullamcorper purus name sample todos1 - due date + due date 0 + today + tags sampleTag3 @@ -60,8 +66,10 @@ Duis at congue nisl. In pharetra vitae nibh at finibus. Aenean ullamcorper purus name sample todos2 - due date + due date 0 + today + tags sampleTag2 @@ -73,8 +81,10 @@ Duis at congue nisl. In pharetra vitae nibh at finibus. Aenean ullamcorper purus name sample todos3 - due date + due date 0 + today + tags sampleTag3 diff --git a/thingspy/things.py b/thingspy/things.py index 46250a9..7d85acd 100644 --- a/thingspy/things.py +++ b/thingspy/things.py @@ -63,6 +63,8 @@ class thingspy: cmd.append("-e") cmd.append(applescript) + # print applescript + process = Popen(cmd, stdout=PIPE) out, err = process.communicate() print("out:" + str(out))