Permalink
Browse files

adds *@remind*

  • Loading branch information...
1 parent 70a6eb3 commit 204136670d471372de1d6812217b5be631f48467 @bevesce committed Aug 10, 2013
Showing with 58 additions and 6 deletions.
  1. +6 −1 README.md
  2. +7 −1 topy/src/todolist_utils.py
  3. +21 −0 utilities/create_reminder.py
  4. +2 −4 utilities/end_the_day.py
  5. +22 −0 utilities/remind.py
View
@@ -10,6 +10,7 @@ This is something that I use everyday and works as it is but I add things when I
# Changelog #
+- 2013-08-10 - added actions for **@remind** tag
- 2013-08-10 - added actions for **@followup** tag
- 2013-08-10 - added todify - iOS pythonista script that adds task tagged with *@today* to notification center
- 2013-05-19 - minor improvement in how abbreviations in queries are expanded
@@ -291,7 +292,7 @@ At the moment no tasks are removed from Onhold.todo.
### end_the_day
-Joins several of other scripts. Launchd runs it for me at the and of the day.
+Joins several of other scripts. Launchd runs it for me at the and of the day.
### reminders_to_topy ###
@@ -300,6 +301,10 @@ some path must be adjusted in AppleScript *reminders_to_topy.applescript*.
It allows to put items into Inbox with Siri on iOS (just put reminder in *Inbox* list and import it when on Mac or set this script in launchd).
+### remind
+
+Adds items tagged with **@remind(YYYY-MM-DD)** to Reminders.app and changes tag to **@willremind(YYYY-MM-DD)**.
+
### itopy, utopy, qtopy, todify ###
Version of script to use in [Pythonista](http://omz-software.com/pythonista/) iOS app. Most of the source was merged to not clutter scripts list in app. Requires [seamless dropbox](https://github.com/bevesce/Seamless-Dropbox)
@@ -29,7 +29,9 @@ def custom_tag_regexp(tag):
def add_tag_to_text(text, tag, param=None):
if text[-1] != ' ':
text += ' '
- text += "@" + tag
+ if not tag.startswith('@'):
+ tag = '@' + tag
+ text += tag
if param:
text += '({0})'.format(param)
return text
@@ -84,6 +86,10 @@ def remove_trailing_tags(line):
return ' @'.join(sp[0:idx])
+def remove_tags(line):
+ return tag_pattern.sub('', line)
+
+
def extract_content(typ, line):
text = extract_text(typ, line)
if typ in ('task', 'note'):
@@ -0,0 +1,21 @@
+import subprocess
+
+applescript_template = """tell application \\"Reminders\\"
+ set r to make new reminder
+ set name of r to \\"{name}\\"
+ set body of r to \\"{body}\\"
+ set remind me date of r to date \\"{reminde_me_date}\\"
+end tell"""
+
+
+def create_reminder(name, body, reminde_me_date):
+ reminde_me_date = reminde_me_date.strftime('%d-%m-%Y %H:%M')
+ applescript = applescript_template.format(
+ name=name,
+ body=body,
+ reminde_me_date=reminde_me_date,
+ )
+ cmd = 'echo "{0}" | osascript'.format(applescript)
+ subprocess.check_output(
+ cmd, shell=True
+ )
View
@@ -3,12 +3,12 @@
import topy
# from archive import archive
from update_lists import update_daily, update_weekly, update_waiting, update_followups
+from remind import set_reminders
from tvcal import tvcal
from log_to_day_one import log_to_day_one
all_lists = topy.from_files(topy.lists.to_list())
inbox_file = open(inbox_path, 'a')
-# archive_list = topy.from_file(archive_path)
onhold_list = topy.from_file(onhold_path)
log_to_day_one(all_lists.deep_copy())
@@ -18,10 +18,8 @@
pass
update_weekly(onhold_list, inbox_file)
update_waiting(onhold_list, inbox_file)
-# inbox_file.close()
update_daily(all_lists)
-# archive(all_lists, archive_list)
update_followups(all_lists)
-# archive_list.to_file(archive_path)
+set_reminders(all_lists)
topy.save(all_lists)
View
@@ -0,0 +1,22 @@
+from datetime import datetime
+from create_reminder import create_reminder
+import topy
+
+
+def set_reminders(todolist):
+ for item in todolist.filter('@remind +d'):
+ if item.has_tag('@remind'):
+ remind_date_str = item.get_tag_param('@remind')
+ remind_date = datetime.strptime(remind_date_str, '%Y-%m-%d %H:%M')
+ item.remove_tag('remind')
+ create_reminder(
+ item.title.text,
+ item.sub_tasks.as_plain_text(indent=False) if item.sub_tasks else '',
+ remind_date,
+ )
+ item.tag('willremind', param=remind_date_str)
+
+if __name__ == '__main__':
+ all_lists = topy.from_files(topy.lists.to_list())
+ set_reminders(all_lists)
+ topy.save(all_lists)

0 comments on commit 2041366

Please sign in to comment.