diff --git a/todoist_interface/gitlab.py b/todoist_interface/gitlab.py index ee13b1e..e231a70 100644 --- a/todoist_interface/gitlab.py +++ b/todoist_interface/gitlab.py @@ -4,9 +4,15 @@ import requests def convert_to_todoist(issues): tasks = [] for issue in issues: - content = "[{title}]({url})".format(title=issue["title"], - url=issue["web_url"]) - tasks.append({"content": content, "label_ids": [2158782094, ]}) + content = "[{title}]({url})".format(title=issue["title"], url=issue["web_url"]) + tasks.append( + { + "content": content, + "label_ids": [ + 2158782094, + ], + } + ) return tasks @@ -24,11 +30,15 @@ class GitlabAPI: """ # Get all issues assigned to the user - url = (self.url - + 'issues?assignee_username=' - + assignee - + '&state=opened&scope=all') - response = requests.get(url, headers={'PRIVATE-TOKEN': self.token}, verify=False) + url = ( + self.url + + "issues?assignee_username=" + + assignee + + "&state=opened&scope=all" + ) + response = requests.get( + url, headers={"PRIVATE-TOKEN": self.token}, verify=False + ) issues = response.json() return issues diff --git a/todoist_interface/mantishub.py b/todoist_interface/mantishub.py index 3e3e73b..711c457 100644 --- a/todoist_interface/mantishub.py +++ b/todoist_interface/mantishub.py @@ -5,11 +5,16 @@ def convert_to_todoist(tickets): # TODO: add a function to convert mantis priority to todoist priority tasks = [] for ticket in tickets: - url = ("https://contria.mantishub.io/view.php?id=" - + str(ticket["id"])) - content = "[{title}]({url})".format(title=ticket["summary"], - url=url) - tasks.append({"content": content, "label_ids": [2158784659, ]}) + url = "https://contria.mantishub.io/view.php?id=" + str(ticket["id"]) + content = "[{title}]({url})".format(title=ticket["summary"], url=url) + tasks.append( + { + "content": content, + "label_ids": [ + 2158784659, + ], + } + ) return tasks @@ -22,6 +27,7 @@ class MantishubAPI: def get_tickets(self): response = requests.get( self.url + "issues?filter_id=assigned", - headers={"Authorization": self.token}) + headers={"Authorization": self.token}, + ) tickets = response.json() return convert_to_todoist(tickets["issues"]) diff --git a/todoist_interface/settings.py b/todoist_interface/settings.py index d44422a..cf4f677 100644 --- a/todoist_interface/settings.py +++ b/todoist_interface/settings.py @@ -2,6 +2,6 @@ import yaml def read_config(config_path): - with open(config_path, 'r') as ymlfile: + with open(config_path, "r") as ymlfile: cfg = yaml.load(ymlfile, Loader=yaml.FullLoader) return cfg diff --git a/todoist_interface/todoist.py b/todoist_interface/todoist.py index 018719f..a63ff42 100644 --- a/todoist_interface/todoist.py +++ b/todoist_interface/todoist.py @@ -14,9 +14,10 @@ class TodoistAPI: Returns all tasks from todoist """ response = requests.get( - self.url + 'tasks', - headers={'Authorization': 'Bearer ' + self.token}, - params={"filter": todoist_filter}) + self.url + "tasks", + headers={"Authorization": "Bearer " + self.token}, + params={"filter": todoist_filter}, + ) return response.json() def create_tasks(self, tasks: list, labels: list): @@ -24,13 +25,12 @@ class TodoistAPI: Adds tasks to todoist """ for task in tasks: - requests.post(self.url + 'tasks', - headers={ - "Content-Type": "application/json", - "X-Request-Id": str(uuid.uuid4()), - "Authorization": "Bearer " - + self.token}, - data=json.dumps({ - "content": task["content"], - "labels": labels - })) + requests.post( + self.url + "tasks", + headers={ + "Content-Type": "application/json", + "X-Request-Id": str(uuid.uuid4()), + "Authorization": "Bearer " + self.token, + }, + data=json.dumps({"content": task["content"], "labels": labels}), + )