Get relevant todoist tasks
This commit is contained in:
parent
7790e3a677
commit
b8eb2645e7
7 changed files with 45 additions and 1 deletions
|
@ -0,0 +1,2 @@
|
|||
todoist-python==8.1.1
|
||||
urlextract==0.14.0
|
|
@ -4,4 +4,4 @@ set -e
|
|||
|
||||
PATH=env/bin:${PATH}
|
||||
|
||||
python3 todoist-github/cli.py
|
||||
python3 -m todoist-github
|
||||
|
|
0
todoist-github/__init__.py
Normal file
0
todoist-github/__init__.py
Normal file
3
todoist-github/__main__.py
Normal file
3
todoist-github/__main__.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from .cli import main
|
||||
|
||||
main()
|
|
@ -1 +1,22 @@
|
|||
#!/usr/bin/env python3
|
||||
from .clients import todoist
|
||||
from .utils import get_github_task
|
||||
|
||||
|
||||
def get_relevant_todoist_tasks():
|
||||
todoist.items.sync()
|
||||
tasks = {}
|
||||
for task in todoist.items.all():
|
||||
if get_github_task(task["content"]):
|
||||
tasks[task['content']] = task
|
||||
return tasks
|
||||
|
||||
|
||||
def main():
|
||||
todoist_tasks = get_relevant_todoist_tasks()
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
4
todoist-github/clients.py
Normal file
4
todoist-github/clients.py
Normal file
|
@ -0,0 +1,4 @@
|
|||
from todoist import TodoistAPI
|
||||
import os
|
||||
|
||||
todoist = TodoistAPI(os.environ["TODOIST_TOKEN"])
|
14
todoist-github/utils.py
Normal file
14
todoist-github/utils.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from typing import Optional
|
||||
from urlextract import URLExtract
|
||||
from urllib.parse import urlparse
|
||||
|
||||
|
||||
extractor = URLExtract()
|
||||
|
||||
|
||||
def get_github_task(content) -> Optional[str]:
|
||||
if "github" not in content.lower():
|
||||
return None
|
||||
for url in extractor.gen_urls(content):
|
||||
if urlparse(url).netloc == "github.com":
|
||||
return url
|
Reference in a new issue