Last active
July 4, 2018 15:38
-
-
Save lordcirth/f157c369537c72e65ad1db6a4a124098 to your computer and use it in GitHub Desktop.
Taskwarrior RT hook
This file contains hidden or 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 python | |
# Autodetect RT numbers and add the RT link as an annotation | |
import sys | |
import json | |
import re | |
added_task = json.loads(sys.stdin.readline()) | |
rt_regex = re.compile(".*RT#?(\d+).*") | |
rt_baseurl = "https://rt.uwaterloo.ca/Ticket/Display.html?id=" | |
#print added_task | |
desc = added_task['description'] | |
if rt_regex.match(desc): | |
rt_number = rt_regex.match(desc).group(1) #Eg "RT800000" | |
rt_url = rt_baseurl + rt_number | |
entry_date = added_task['entry'] | |
# TODO: Escape url /'s ? | |
annos = [ { "entry": entry_date, "description": rt_url } ] | |
added_task['annotations'] = annos | |
print "RT Link Added." | |
print(json.dumps(added_task)) | |
sys.exit(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment