Created
August 19, 2020 20:41
-
-
Save brandtg/f8c4998ca41e8b1fa0fafe0bdac48838 to your computer and use it in GitHub Desktop.
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 python3 | |
import argparse | |
import logging | |
import sys | |
import json | |
import re | |
def find_tasks(data, name=None): | |
for task in data["data"]: | |
if name is None or task["assignee"]["name"] == name: | |
yield { | |
"title": task["name"], | |
"note": task["notes"], | |
"url": task["permalink_url"], | |
} | |
def clean_note_line(line): | |
line = re.sub(r"\s*\-", "", line) | |
return line | |
def format_taskpaper(task): | |
lines = [] | |
lines.append("- {} @parallel(true) @autodone(false)".format(task["title"])) | |
lines.append("\t{}".format(task["url"])) | |
lines.append("\t") | |
if task.get("note"): | |
lines.extend( | |
["\t{}".format(clean_note_line(line)) for line in task["note"].split("\n")] | |
) | |
return "\n".join(lines) | |
if __name__ == "__main__": | |
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.INFO) | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--name", default="Greg Brandt") | |
args = parser.parse_args() | |
for task in find_tasks(json.load(sys.stdin), name=args.name): | |
sys.stdout.write(format_taskpaper(task)) | |
sys.stdout.write("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment