Source code for plaid.types.cgns_types

"""Custom types for CGNS data structures."""

# -*- coding: utf-8 -*-
#
# This file is subject to the terms and conditions defined in
# file 'LICENSE.txt', which is part of this source code package.
#
#

from typing import Any, Optional

from pydantic import BaseModel, Field

try:
    from typing import TypeAlias  # Python 3.10+
except ImportError:  # pragma: no cover
    from typing_extensions import TypeAlias


[docs] class CGNSNode(BaseModel): """Custom type for a CGNS node."""
[docs] name: str = Field(..., description="The name of the CGNS node.")
[docs] value: Optional[Any] = Field( None, description="The value of the CGNS node, which can be of any type or None.", )
[docs] children: list["CGNSNode"] = Field( default_factory=list, description="A list of child CGNS nodes." )
[docs] label: str = Field(..., description="The label of the CGNS node.")
# A CGNSTree is simply the root CGNSNode
[docs] CGNSTree: TypeAlias = CGNSNode
# CGNS links and paths
[docs] CGNSPath: TypeAlias = tuple[str, ...] # a path in the CGNS tree