From 24a409cfcf2e14078e5f3bdff5aa140f81bb663b Mon Sep 17 00:00:00 2001 From: Angelina Tingaeva Date: Tue, 5 Dec 2023 18:26:18 +0500 Subject: [PATCH] check for gid existing --- mapping.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mapping.py b/mapping.py index 7fae977..1a71386 100644 --- a/mapping.py +++ b/mapping.py @@ -101,6 +101,9 @@ def create_tasks_in_tracker(data): ya_imported_task_response = {} for task in data: + if 'gid' not in task: + continue + if task.get('assignee') and 'gid' in task['assignee']: ya_assignee = assignee.get(task['assignee']['gid'], 'dr.cyrill') else: @@ -144,11 +147,12 @@ def create_tasks_in_tracker(data): for gid, parent_id in parent_task_ids.items(): assign_parent_task(gid, parent_id) + #и эта функция для родительской задачи написана -def assign_parent_task(child_gid, parent_id): +def assign_parent_task(gid, parent_id): """ Назначение родительской задачи """ - base_url = f'https://api.tracker.yandex.net/v2/issues/{child_gid}' + base_url = f'https://api.tracker.yandex.net/v2/issues/{gid}' headers = { 'Host': 'api.tracker.yandex.net', 'Authorization': 'OAuth y0_AgAEA7qkB3KjAArkXwAAAADzMlP9oR1lwMzBS2e94jHzdnII8Laxi7k', @@ -176,6 +180,7 @@ def assign_parent_task(child_gid, parent_id): logger.debug('Response: %s', response.content) # здесь я закончила добавлять про родительскую задачу с большой надеждой + file = open(asana_data_json, "r", encoding="utf8") json_data = json.loads(file.read())