Format with black
This commit is contained in:
parent
d74aae0639
commit
1886bd26db
|
@ -4,9 +4,15 @@ import requests
|
||||||
def convert_to_todoist(issues):
|
def convert_to_todoist(issues):
|
||||||
tasks = []
|
tasks = []
|
||||||
for issue in issues:
|
for issue in issues:
|
||||||
content = "[{title}]({url})".format(title=issue["title"],
|
content = "[{title}]({url})".format(title=issue["title"], url=issue["web_url"])
|
||||||
url=issue["web_url"])
|
tasks.append(
|
||||||
tasks.append({"content": content, "label_ids": [2158782094, ]})
|
{
|
||||||
|
"content": content,
|
||||||
|
"label_ids": [
|
||||||
|
2158782094,
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
return tasks
|
return tasks
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,11 +30,15 @@ class GitlabAPI:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Get all issues assigned to the user
|
# Get all issues assigned to the user
|
||||||
url = (self.url
|
url = (
|
||||||
+ 'issues?assignee_username='
|
self.url
|
||||||
+ assignee
|
+ "issues?assignee_username="
|
||||||
+ '&state=opened&scope=all')
|
+ assignee
|
||||||
response = requests.get(url, headers={'PRIVATE-TOKEN': self.token}, verify=False)
|
+ "&state=opened&scope=all"
|
||||||
|
)
|
||||||
|
response = requests.get(
|
||||||
|
url, headers={"PRIVATE-TOKEN": self.token}, verify=False
|
||||||
|
)
|
||||||
issues = response.json()
|
issues = response.json()
|
||||||
|
|
||||||
return issues
|
return issues
|
||||||
|
|
|
@ -5,11 +5,16 @@ def convert_to_todoist(tickets):
|
||||||
# TODO: add a function to convert mantis priority to todoist priority
|
# TODO: add a function to convert mantis priority to todoist priority
|
||||||
tasks = []
|
tasks = []
|
||||||
for ticket in tickets:
|
for ticket in tickets:
|
||||||
url = ("https://contria.mantishub.io/view.php?id="
|
url = "https://contria.mantishub.io/view.php?id=" + str(ticket["id"])
|
||||||
+ str(ticket["id"]))
|
content = "[{title}]({url})".format(title=ticket["summary"], url=url)
|
||||||
content = "[{title}]({url})".format(title=ticket["summary"],
|
tasks.append(
|
||||||
url=url)
|
{
|
||||||
tasks.append({"content": content, "label_ids": [2158784659, ]})
|
"content": content,
|
||||||
|
"label_ids": [
|
||||||
|
2158784659,
|
||||||
|
],
|
||||||
|
}
|
||||||
|
)
|
||||||
return tasks
|
return tasks
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +27,7 @@ class MantishubAPI:
|
||||||
def get_tickets(self):
|
def get_tickets(self):
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
self.url + "issues?filter_id=assigned",
|
self.url + "issues?filter_id=assigned",
|
||||||
headers={"Authorization": self.token})
|
headers={"Authorization": self.token},
|
||||||
|
)
|
||||||
tickets = response.json()
|
tickets = response.json()
|
||||||
return convert_to_todoist(tickets["issues"])
|
return convert_to_todoist(tickets["issues"])
|
||||||
|
|
|
@ -2,6 +2,6 @@ import yaml
|
||||||
|
|
||||||
|
|
||||||
def read_config(config_path):
|
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)
|
cfg = yaml.load(ymlfile, Loader=yaml.FullLoader)
|
||||||
return cfg
|
return cfg
|
||||||
|
|
|
@ -14,9 +14,10 @@ class TodoistAPI:
|
||||||
Returns all tasks from todoist
|
Returns all tasks from todoist
|
||||||
"""
|
"""
|
||||||
response = requests.get(
|
response = requests.get(
|
||||||
self.url + 'tasks',
|
self.url + "tasks",
|
||||||
headers={'Authorization': 'Bearer ' + self.token},
|
headers={"Authorization": "Bearer " + self.token},
|
||||||
params={"filter": todoist_filter})
|
params={"filter": todoist_filter},
|
||||||
|
)
|
||||||
return response.json()
|
return response.json()
|
||||||
|
|
||||||
def create_tasks(self, tasks: list, labels: list):
|
def create_tasks(self, tasks: list, labels: list):
|
||||||
|
@ -24,13 +25,12 @@ class TodoistAPI:
|
||||||
Adds tasks to todoist
|
Adds tasks to todoist
|
||||||
"""
|
"""
|
||||||
for task in tasks:
|
for task in tasks:
|
||||||
requests.post(self.url + 'tasks',
|
requests.post(
|
||||||
headers={
|
self.url + "tasks",
|
||||||
"Content-Type": "application/json",
|
headers={
|
||||||
"X-Request-Id": str(uuid.uuid4()),
|
"Content-Type": "application/json",
|
||||||
"Authorization": "Bearer "
|
"X-Request-Id": str(uuid.uuid4()),
|
||||||
+ self.token},
|
"Authorization": "Bearer " + self.token,
|
||||||
data=json.dumps({
|
},
|
||||||
"content": task["content"],
|
data=json.dumps({"content": task["content"], "labels": labels}),
|
||||||
"labels": labels
|
)
|
||||||
}))
|
|
||||||
|
|
Loading…
Reference in New Issue