refactor(mapping): add utf8, шеукф
first iteration on data["data"]/Users/angelinatingaeva/HEADO_1/Mapping_ya_tracker/venv/bin/python /Users/angelinatingaeva/HEADO_1/Mapping_ya_tracker/mapping.py /- -.
This commit is contained in:
parent
6cb1f3aae5
commit
01a05c045d
@ -33,7 +33,7 @@ def extract_unique_names_and_ids(data):
|
|||||||
|
|
||||||
|
|
||||||
def export_to_csv(unique_names, unique_ids):
|
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 = csv.writer(csvfile, delimiter=",")
|
||||||
writer.writerow(["Name", "ID"])
|
writer.writerow(["Name", "ID"])
|
||||||
|
|
||||||
|
35
mapping.py
35
mapping.py
@ -1,22 +1,23 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from yandex_tracker_client import TrackerClient
|
from yandex_tracker_client import TrackerClient
|
||||||
|
|
||||||
|
|
||||||
|
YANDEX_TRACKER_TOKEN = 'y0_AgAEA7qkfTFqAArTqQAAAADyduv806rRKh8MS6GOg01ZdwPE-F4ZHuQ'
|
||||||
|
ORG_ID = '35d164dcf81e48f2b6a532f4badddd33'
|
||||||
|
|
||||||
client = TrackerClient(
|
client = TrackerClient(
|
||||||
token='YANDEX_TRACKER_TOKEN',
|
token='YANDEX_TRACKER_TOKEN',
|
||||||
org_id='ORG_ID'
|
org_id='ORG_ID'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
YANDEX_TRACKER_TOKEN = 'y0_AgAEA7qkfTFqAArTqQAAAADyduv806rRKh8MS6GOg01ZdwPE-F4ZHuQ'
|
|
||||||
ORG_ID = '35d164dcf81e48f2b6a532f4badddd33'
|
|
||||||
|
|
||||||
|
|
||||||
base_dir = os.path.dirname(os.path.realpath(__file__))
|
base_dir = os.path.dirname(os.path.realpath(__file__))
|
||||||
asana_data_json = os.path.join(base_dir, './data/data_asana.json')
|
asana_data_json = os.path.join(base_dir, './data/data_asana.json')
|
||||||
|
|
||||||
|
sys.stdout.reconfigure(encoding='utf-8')
|
||||||
|
|
||||||
# ниже функция для случаев, когда не будет готового файла для импорта
|
# ниже функция для случаев, когда не будет готового файла для импорта
|
||||||
# def get_data_from_asana():
|
# def get_data_from_asana():
|
||||||
@ -34,14 +35,14 @@ def transform_data(data):
|
|||||||
""" Преобразование данных из Asana в ЯндексТрекер в совместимом формате """
|
""" Преобразование данных из Asana в ЯндексТрекер в совместимом формате """
|
||||||
|
|
||||||
transformed_data = []
|
transformed_data = []
|
||||||
for task in data:
|
for task in data["data"]:
|
||||||
transformed_task = {
|
transformed_task = {
|
||||||
'summary': task['name'],
|
'summary': task['name'],
|
||||||
'description': task['notes'],
|
'description': task['notes'],
|
||||||
'createdAt': task['created_at'],
|
'createdAt': task['created_at'],
|
||||||
'deadline': task['due_on'],
|
'deadline': task['due_on'],
|
||||||
'assignee': task['assignee'],
|
'assignee': task['assignee'],
|
||||||
'milestone': task['section'],
|
# 'milestone': task['section'],
|
||||||
# 'memberships': task['memberships'],
|
# 'memberships': task['memberships'],
|
||||||
# 'parent': task[''],
|
# 'parent': task[''],
|
||||||
'status': task['completed'],
|
'status': task['completed'],
|
||||||
@ -55,7 +56,7 @@ def create_tasks_in_tracker(data):
|
|||||||
|
|
||||||
base_url = 'https://api.tracker.yandex.net/v2/issues'
|
base_url = 'https://api.tracker.yandex.net/v2/issues'
|
||||||
headers = {
|
headers = {
|
||||||
'Authorization': 'YANDEX_TRACKER_TOKEN',
|
'Authorization': 'ORG_ID',
|
||||||
'Content-Type': 'asana_data_json',
|
'Content-Type': 'asana_data_json',
|
||||||
}
|
}
|
||||||
for task in data:
|
for task in data:
|
||||||
@ -65,7 +66,7 @@ def create_tasks_in_tracker(data):
|
|||||||
'createdAt': task['createdAt'],
|
'createdAt': task['createdAt'],
|
||||||
'deadline': task['deadline'],
|
'deadline': task['deadline'],
|
||||||
'assignee': task['assignee'],
|
'assignee': task['assignee'],
|
||||||
'milestone': task['milestone'],
|
# 'milestone': task['milestone'],
|
||||||
# 'memberships': task['memberships'],
|
# 'memberships': task['memberships'],
|
||||||
# 'parent': task['parent'],
|
# 'parent': task['parent'],
|
||||||
'status': task['status'],
|
'status': task['status'],
|
||||||
@ -84,15 +85,9 @@ def create_tasks_in_tracker(data):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
# asana_data = get_data_from_asana()
|
||||||
""" Основная функция для переноса данных """
|
file = open(asana_data_json, "r", encoding="utf8")
|
||||||
# asana_data = get_data_from_asana()
|
json_data = json.loads(file.read())
|
||||||
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)
|
|
||||||
|
|
||||||
|
yandex_tracker_data = transform_data(json_data)
|
||||||
# Запуск основной функции
|
create_tasks_in_tracker(yandex_tracker_data)
|
||||||
main()
|
|
||||||
|
9
users.mapping.asana2ya.csv
Normal file
9
users.mapping.asana2ya.csv
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
Name,ID
|
||||||
|
IrinaOs,698025068994499
|
||||||
|
Сергей Анисов,547756841476
|
||||||
|
Илья,2495641457848
|
||||||
|
Malkova,1204278463134045
|
||||||
|
Sergey Volodin,1202859655765863
|
||||||
|
Никита,1203071663735925
|
||||||
|
Cyrill Gafarov,2934206415688
|
||||||
|
Diza,2495641457856
|
|
Loading…
Reference in New Issue
Block a user