♻️ remove dataclasses

we can't use dataclasses in pyblish plugins until new version of pyblish-base is propagated to AYON ecosystem
This commit is contained in:
Ondřej Samohel 2025-06-27 13:30:46 +02:00
parent 3c3b165e36
commit 358efdb898
No known key found for this signature in database
GPG key ID: 02376E18990A97C6

View file

@ -1,9 +1,9 @@
"""Integrate representations with traits."""
from __future__ import annotations
import contextlib
import copy
import hashlib
import json
from dataclasses import dataclass
from pathlib import Path
from typing import TYPE_CHECKING, Any
@ -62,7 +62,6 @@ if TYPE_CHECKING:
)
@dataclass(frozen=True)
class TransferItem:
"""Represents a single transfer item.
@ -85,10 +84,29 @@ class TransferItem:
size: int
checksum: str
template: str
template_data: "dict[str, Any]"
template_data: dict[str, Any]
representation: Representation
related_trait: FileLocation
def __init__(self,
source: Path,
destination: Path,
size: int,
checksum: str,
template: str,
template_data: dict[str, Any],
representation: Representation,
related_trait: FileLocation):
self.source = source
self.destination = destination
self.size = size
self.checksum = checksum
self.template = template
self.template_data = template_data
self.representation = representation
self.related_trait = related_trait
@staticmethod
def get_size(file_path: Path) -> int:
"""Get the size of the file.
@ -118,7 +136,6 @@ class TransferItem:
).hexdigest()
@dataclass
class TemplateItem:
"""Represents single template item.
@ -130,24 +147,73 @@ class TemplateItem:
template_data (dict[str, Any]): Template data.
template_object (AnatomyTemplateItem): Template object
"""
anatomy: "Anatomy"
anatomy: Anatomy
template: str
template_data: "dict[str, Any]"
template_object: "AnatomyTemplateItem"
template_data: dict[str, Any]
template_object: AnatomyTemplateItem
def __init__(self,
anatomy: Anatomy,
template: str,
template_data: dict[str, Any],
template_object: AnatomyTemplateItem):
"""Initialize TemplateItem.
Args:
anatomy (Anatomy): Anatomy object.
template (str): Template path.
template_data (dict[str, Any]): Template data.
template_object (AnatomyTemplateItem): Template object.
"""
self.anatomy = anatomy
self.template = template
self.template_data = template_data
self.template_object = template_object
@dataclass
class RepresentationEntity:
"""Representation entity data."""
id: str
versionId: str # noqa: N815
name: str
files: "dict[str, Any]"
attrib: "dict[str, Any]"
files: dict[str, Any]
attrib: dict[str, Any]
data: str
tags: "list[str]"
tags: list[str]
status: str
def __init__(self,
id: str,
versionId: str, # noqa: N815
name: str,
files: dict[str, Any],
attrib: dict[str, Any],
data: str,
tags: list[str],
status: str):
"""Initialize RepresentationEntity.
Args:
id (str): Entity ID.
versionId (str): Version ID.
name (str): Representation name.
files (dict[str, Any]): Files in the representation.
attrib (dict[str, Any]): Attributes of the representation.
data (str): Data of the representation.
tags (list[str]): Tags of the representation.
status (str): Status of the representation.
"""
self.id = id
self.versionId = versionId
self.name = name
self.files = files
self.attrib = attrib
self.data = data
self.tags = tags
self.status = status
def get_instance_families(instance: pyblish.api.Instance) -> "list[str]":
"""Get all families of the instance.