Compare commits

..

No commits in common. "de88475e40ad12224cfd0f38bbd04660c0b99e59" and "6cb1f3aae58a537481d475dc0c5b58054e0945fb" have entirely different histories.

3 changed files with 21 additions and 25 deletions

View File

@ -33,7 +33,7 @@ def extract_unique_names_and_ids(data):
def export_to_csv(unique_names, unique_ids):
with open("users.mapping.asana2ya.csv", "w", newline="") as csvfile:
with open("output.csv", "w", newline="") as csvfile:
writer = csv.writer(csvfile, delimiter=",")
writer.writerow(["Name", "ID"])

View File

@ -1,23 +1,22 @@
import json
import os
import sys
import requests
from yandex_tracker_client import TrackerClient
YANDEX_TRACKER_TOKEN = 'y0_AgAAAABAmFP8AArTqQAAAADyyFLmOoHqPprnRKag6B8okqjoDx2m9P0'
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():
@ -35,14 +34,14 @@ def transform_data(data):
""" Преобразование данных из Asana в ЯндексТрекер в совместимом формате """
transformed_data = []
for task in data["data"]:
for task in 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'],
@ -56,7 +55,7 @@ def create_tasks_in_tracker(data):
base_url = 'https://api.tracker.yandex.net/v2/issues'
headers = {
'Authorization': 'ORG_ID',
'Authorization': 'YANDEX_TRACKER_TOKEN',
'Content-Type': 'asana_data_json',
}
for task in data:
@ -66,7 +65,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'],
@ -85,9 +84,15 @@ def create_tasks_in_tracker(data):
)
def main():
""" Основная функция для переноса данных """
# asana_data = get_data_from_asana()
file = open(asana_data_json, "r", encoding="utf8")
json_data = json.loads(file.read())
yandex_tracker_data = transform_data(json_data)
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)
# Запуск основной функции
main()

View File

@ -1,9 +0,0 @@
Name,ID
IrinaOs,698025068994499
Сергей Анисов,547756841476
Илья,2495641457848
Malkova,1204278463134045
Sergey Volodin,1202859655765863
Никита,1203071663735925
Cyrill Gafarov,2934206415688
Diza,2495641457856
1 Name ID
2 IrinaOs 698025068994499
3 Сергей Анисов 547756841476
4 Илья 2495641457848
5 Malkova 1204278463134045
6 Sergey Volodin 1202859655765863
7 Никита 1203071663735925
8 Cyrill Gafarov 2934206415688
9 Diza 2495641457856