Format with black
This commit is contained in:
parent
d74aae0639
commit
1886bd26db
|
@ -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
|
||||
|
|
|
@ -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"])
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}),
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue