Created
August 18, 2016 14:46
-
-
Save andir/dc29d470f5df6206628d4d090094c869 to your computer and use it in GitHub Desktop.
convert taskwarrior tasks to ical entries when they have a scheduled date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import os.path | |
from ics import Calendar, Event | |
import subprocess | |
import json | |
def read_tasks(): | |
output = subprocess.check_output(['task', 'export']) | |
for task in json.loads(output.decode('utf-8')): | |
if task['status'] == 'completed': | |
continue | |
if 'scheduled' in task: | |
yield task | |
if __name__ == "__main__": | |
c = Calendar() | |
for task in read_tasks(): | |
e = Event() | |
e.name = task['description'] | |
e.begin = task['scheduled'] | |
c.events.append(e) | |
with open(os.path.expanduser('~/.local/share/calendar/tasks/tasks.ics'), 'w') as f: | |
f.writelines(c) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ok. That's the solution that worked for me with datetime package (with my corresponding timezone: + 2 hours). I also collected the
due
field instead of thescheduled
field: