Skip to content

anatomy

parse_statuses(addon, kitsu_project_id) async

Map kitsu status to ayon status

Kitsu structure:

{ "name": "Retake", "archived": false, "short_name": "retake", "color": "#ff3860", "is_done": false, "is_artist_allowed": true, "is_client_allowed": true, "is_retake": true, "is_feedback_request": false, "is_default": false, "shotgun_id": null, "id": "500acc0f-2355-44b1-9cde-759287084c05", "created_at": "2023-06-21T19:02:07", "updated_at": "2023-06-21T19:02:07", "type": "TaskStatus" },

Ayon structure:

name
shortName
state: Literal["not_started", "in_progress", "done", "blocked"]
icon
color
Source code in server/kitsu/anatomy.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
async def parse_statuses(
    addon: "KitsuAddon", kitsu_project_id: str
) -> list[Status]:
    """Map kitsu status to ayon status

    Kitsu structure:

      {
        "name": "Retake",
        "archived": false,
        "short_name": "retake",
        "color": "#ff3860",
        "is_done": false,
        "is_artist_allowed": true,
        "is_client_allowed": true,
        "is_retake": true,
        "is_feedback_request": false,
        "is_default": false,
        "shotgun_id": null,
        "id": "500acc0f-2355-44b1-9cde-759287084c05",
        "created_at": "2023-06-21T19:02:07",
        "updated_at": "2023-06-21T19:02:07",
        "type": "TaskStatus"
      },

    Ayon structure:

        name
        shortName
        state: Literal["not_started", "in_progress", "done", "blocked"]
        icon
        color

    """

    task_status_response = await addon.kitsu.get("data/task-status")
    if task_status_response.status_code != 200:
        raise AyonException("Could not get Kitsu statuses")

    result: list[Status] = []
    kitsu_statuses = task_status_response.json()
    kitsu_statuses.sort(key=lambda x: not x.get("is_default"))
    settings = await addon.get_studio_settings()

    for status in kitsu_statuses:
        found = False
        for (
            settings_status
        ) in settings.sync_settings.default_sync_info.default_status_info:
            if status["short_name"] == settings_status.short_name:
                found = True
                status["icon"] = settings_status.icon
                status["state"] = settings_status.state
        if not found:
            status["icon"] = "task_alt"
            status["state"] = "in_progress"

    for kitsu_status in kitsu_statuses:
        status = Status(
            name=kitsu_status["name"],
            shortName=kitsu_status["short_name"],
            color=kitsu_status["color"],
            state=kitsu_status["state"],
            icon=kitsu_status["icon"],
        )
        result.append(status)
    return result

parse_task_types(addon, kitsu_project_id) async

Kitsy structure:

{ "name": "Lookdev", "short_name": "", "color": "#64B5F6", "priority": 3, "for_entity": "Asset", "allow_timelog": true, "archived": false, "shotgun_id": null, "department_id": "3730aeca-1911-483b-819d-79afd99c984b", "id": "ff41528d-4a3c-4e09-ae88-b879047a5104", "created_at": "2023-06-21T19:02:07", "updated_at": "2023-06-28T14:49:45", "type": "TaskType" }

Ayon structure:

name: shortName: icon:

Source code in server/kitsu/anatomy.py
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
async def parse_task_types(
    addon: "KitsuAddon", kitsu_project_id: str
) -> list[TaskType]:
    """

    Kitsy structure:

    {
      "name": "Lookdev",
      "short_name": "",
      "color": "#64B5F6",
      "priority": 3,
      "for_entity": "Asset",
      "allow_timelog": true,
      "archived": false,
      "shotgun_id": null,
      "department_id": "3730aeca-1911-483b-819d-79afd99c984b",
      "id": "ff41528d-4a3c-4e09-ae88-b879047a5104",
      "created_at": "2023-06-21T19:02:07",
      "updated_at": "2023-06-28T14:49:45",
      "type": "TaskType"
    }

    Ayon structure:

    name:
    shortName:
    icon:

    """

    task_status_response = await addon.kitsu.get(
        f"data/projects/{kitsu_project_id}/task-types"
    )
    if task_status_response.status_code != 200:
        raise AyonException("Could not get Kitsu task types")
    result: list[TaskType] = []
    for kitsu_task_type in task_status_response.json():
        # Check if the task already exist
        # eg. Concept under Assets and the hardcoded Concept under Concepts
        if any(d.name == kitsu_task_type["name"] for d in result):
            continue

        short_name = None
        icon = None

        settings = await addon.get_studio_settings()
        found = False
        for task in settings.sync_settings.default_sync_info.default_task_info:
            if task.name.lower() == kitsu_task_type["name"].lower():
                found = True
                short_name = task.short_name
                icon = task.icon

        if not found:
            short_name = kitsu_task_type.get("short_name")
            if not short_name:
                name_slug = remove_accents(kitsu_task_type["name"].lower())
                short_name = create_short_name(name_slug)
            icon = "task_alt"

        result.append(
            TaskType(
                name=kitsu_task_type["name"],
                shortName=short_name,
                icon=icon,
            )
        )

    return result