todoist_interface/todoist_interface/__main__.py

26 lines
732 B
Python
Raw Normal View History

2021-11-06 20:48:30 +01:00
import json
2021-11-06 19:06:34 +01:00
import settings
from todoist import TodoistAPI
2021-11-06 19:42:04 +01:00
from gitlab import GitlabAPI
2021-11-06 20:07:57 +01:00
import utils
2021-11-06 19:06:34 +01:00
if __name__ == '__main__':
# initialise the settings
2021-11-06 19:34:33 +01:00
config = settings.read_config("todoist_interface.yml")
2021-11-06 19:06:34 +01:00
2021-11-06 20:07:57 +01:00
# initialise Todoist and Gitlab
2021-11-06 19:06:34 +01:00
todoist = TodoistAPI(config['todoist']['token'])
2021-11-06 19:42:04 +01:00
gitlab = GitlabAPI(config["gitlab"]["url"], config["gitlab"]["token"])
2021-11-06 20:07:57 +01:00
# Get the Todoist tasks
2021-11-06 19:06:34 +01:00
tasks = todoist.get_get_tasks_by_filter("@gitlab")
2021-11-06 20:07:57 +01:00
# Get the Gitlab issues
2021-11-06 20:48:30 +01:00
# issues = gitlab.get_issues_by_assignee("zweili")
2021-11-06 20:07:57 +01:00
# Create a list of issues that are not in Todoist
missing_tasks = utils.get_missing_tasks(tasks, issues)
2021-11-06 20:48:30 +01:00
if missing_tasks:
todoist.create_tasks(missing_tasks)