Skip to content

extract_ayon_project_anatomy

Extract Anatomy object from ayon ProjectEntity.

This file is for the backwards compatibility with Ayon server.

This funciton is a part of the server from version 1.5.1, so we can remove this file after a grace period.

from ayon_server.helpers.extract_anatomy import extract_project_anatomy

extract_ayon_project_anatomy(project)

Extract Anatomy object from ayon ProjectEntity.

Source code in server/kitsu/extract_ayon_project_anatomy.py
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
def extract_ayon_project_anatomy(project: ProjectEntity) -> Anatomy:
    """Extract Anatomy object from ayon ProjectEntity."""

    templates = project.config.get("templates", {}).get("common", {})
    for template_group, template_group_def in project.config.get(
        "templates", {}
    ).items():
        if template_group == "common":
            continue
        templates[template_group] = dict2list(template_group_def)

    result = {
        "templates": templates,
        "roots": dict2list(project.config.get("roots", {})),
        "folder_types": process_aux_table(project.folder_types),
        "task_types": process_aux_table(project.task_types),
        "link_types": process_link_types(project.link_types),
        "statuses": process_aux_table(project.statuses),
        "tags": process_aux_table(project.tags),
        "attributes": project.attrib,
    }

    return Anatomy(**result)

process_aux_table(src)

Process auxiliary table.

Source code in server/kitsu/extract_ayon_project_anatomy.py
24
25
26
27
28
29
def process_aux_table(src: list[dict[str, Any]]) -> list[dict[str, Any]]:
    """Process auxiliary table."""
    result = []
    for data in src:
        result.append({**data, "original_name": data["name"]})
    return result

Convert project linktypes submodel to anatomy-style linktypes.

Source code in server/kitsu/extract_ayon_project_anatomy.py
32
33
34
35
36
37
38
39
40
41
42
43
44
45
def process_link_types(src: list[LinkTypeModel]) -> list[dict[str, Any]]:
    """Convert project linktypes submodel to anatomy-style linktypes."""
    result = []
    for ltdata in src:
        row = {
            "link_type": ltdata.link_type,
            "input_type": ltdata.input_type,
            "output_type": ltdata.output_type,
        }
        for key in ["color", "style"]:
            if value := ltdata.data.get(key):
                row[key] = value
        result.append(row)
    return result