diff --git a/asana_users.py b/asana_users.py index ec26efb..1b91dcb 100644 --- a/asana_users.py +++ b/asana_users.py @@ -33,7 +33,7 @@ def extract_unique_names_and_ids(data): def export_to_csv(unique_names, unique_ids): - with open("output.csv", "w", newline="") as csvfile: + with open("users.mapping.asana2ya.csv", "w", newline="") as csvfile: writer = csv.writer(csvfile, delimiter=",") writer.writerow(["Name", "ID"]) diff --git a/mapping.py b/mapping.py index a95ad61..4572da9 100644 --- a/mapping.py +++ b/mapping.py @@ -1,22 +1,23 @@ import json import os +import sys import requests from yandex_tracker_client import TrackerClient + +YANDEX_TRACKER_TOKEN = 'y0_AgAEA7qkfTFqAArTqQAAAADyduv806rRKh8MS6GOg01ZdwPE-F4ZHuQ' +ORG_ID = '35d164dcf81e48f2b6a532f4badddd33' + client = TrackerClient( token='YANDEX_TRACKER_TOKEN', org_id='ORG_ID' ) - -YANDEX_TRACKER_TOKEN = 'y0_AgAEA7qkfTFqAArTqQAAAADyduv806rRKh8MS6GOg01ZdwPE-F4ZHuQ' -ORG_ID = '35d164dcf81e48f2b6a532f4badddd33' - - base_dir = os.path.dirname(os.path.realpath(__file__)) asana_data_json = os.path.join(base_dir, './data/data_asana.json') +sys.stdout.reconfigure(encoding='utf-8') # ниже функция для случаев, когда не будет готового файла для импорта # def get_data_from_asana(): @@ -34,14 +35,14 @@ def transform_data(data): """ Преобразование данных из Asana в ЯндексТрекер в совместимом формате """ transformed_data = [] - for task in data: + for task in data["data"]: transformed_task = { 'summary': task['name'], 'description': task['notes'], 'createdAt': task['created_at'], 'deadline': task['due_on'], 'assignee': task['assignee'], - 'milestone': task['section'], + # 'milestone': task['section'], # 'memberships': task['memberships'], # 'parent': task[''], 'status': task['completed'], @@ -55,7 +56,7 @@ def create_tasks_in_tracker(data): base_url = 'https://api.tracker.yandex.net/v2/issues' headers = { - 'Authorization': 'YANDEX_TRACKER_TOKEN', + 'Authorization': 'ORG_ID', 'Content-Type': 'asana_data_json', } for task in data: @@ -65,7 +66,7 @@ def create_tasks_in_tracker(data): 'createdAt': task['createdAt'], 'deadline': task['deadline'], 'assignee': task['assignee'], - 'milestone': task['milestone'], + # 'milestone': task['milestone'], # 'memberships': task['memberships'], # 'parent': task['parent'], 'status': task['status'], @@ -84,15 +85,9 @@ def create_tasks_in_tracker(data): ) -def main(): - """ Основная функция для переноса данных """ - # asana_data = get_data_from_asana() - with open(asana_data_json, 'r') as file: - asana_data = json.load(file) - # return asana_data - yandex_tracker_data = transform_data(asana_data) - create_tasks_in_tracker(yandex_tracker_data) +# asana_data = get_data_from_asana() +file = open(asana_data_json, "r", encoding="utf8") +json_data = json.loads(file.read()) - -# Запуск основной функции -main() +yandex_tracker_data = transform_data(json_data) +create_tasks_in_tracker(yandex_tracker_data) diff --git a/users.mapping.asana2ya.csv b/users.mapping.asana2ya.csv new file mode 100644 index 0000000..342a61b --- /dev/null +++ b/users.mapping.asana2ya.csv @@ -0,0 +1,9 @@ +Name,ID +IrinaOs,698025068994499 +Сергей Анисов,547756841476 +Илья,2495641457848 +Malkova,1204278463134045 +Sergey Volodin,1202859655765863 +Никита,1203071663735925 +Cyrill Gafarov,2934206415688 +Diza,2495641457856