trait
Defines the base trait model and representation.
IncompatibleTraitVersionError
Bases: Exception
Incompatible trait version exception.
This exception is raised when the trait version is incompatible with the current version of the trait.
Source code in client/ayon_core/pipeline/traits/trait.py
92 93 94 95 96 97 | |
LooseMatchingTraitError
Bases: Exception, Generic[T]
Loose matching trait exception.
This exception is raised when the trait is found with a loose matching criteria.
Source code in client/ayon_core/pipeline/traits/trait.py
112 113 114 115 116 117 118 119 120 | |
MissingTraitError
Bases: TypeError
Missing trait error exception.
This exception is raised when the trait is missing.
Source code in client/ayon_core/pipeline/traits/trait.py
143 144 145 146 147 | |
TraitBase dataclass
Bases: ABC
Base trait model.
This model must be used as a base for all trait models. id, name, and description are abstract attributes that must be implemented in the derived classes.
Source code in client/ayon_core/pipeline/traits/trait.py
16 17 18 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 89 | |
description abstractmethod property
Abstract attribute for description.
id abstractmethod property
Abstract attribute for ID.
name abstractmethod property
Abstract attribute for name.
as_dict()
Return a trait as a dictionary.
Returns:
| Name | Type | Description |
|---|---|---|
dict | dict | Trait as dictionary. |
Source code in client/ayon_core/pipeline/traits/trait.py
82 83 84 85 86 87 88 89 | |
get_version() classmethod
Get a trait version from ID.
This assumes Trait ID ends with .v{version}. If not, it will return None.
Returns:
| Type | Description |
|---|---|
Optional[int] | Optional[int]: Trait version |
Source code in client/ayon_core/pipeline/traits/trait.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
get_versionless_id() classmethod
Get a trait ID without a version.
Returns:
| Name | Type | Description |
|---|---|---|
str | str | Trait ID without a version. |
Source code in client/ayon_core/pipeline/traits/trait.py
72 73 74 75 76 77 78 79 80 | |
validate_trait(representation)
Validate the trait.
This method should be implemented in the derived classes to validate the trait data. It can be used by traits to validate against other traits in the representation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
representation | Representation | Representation instance. | required |
Source code in client/ayon_core/pipeline/traits/trait.py
43 44 45 46 47 48 49 50 51 52 53 54 | |
TraitValidationError
Bases: Exception
Trait validation error exception.
This exception is raised when the trait validation fails.
Source code in client/ayon_core/pipeline/traits/trait.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
__init__(scope, message)
Initialize the exception.
We could determine the scope from the stack in the future, provided the scope is always Trait name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scope | str | Scope of the error. | required |
message | str | Error message. | required |
Source code in client/ayon_core/pipeline/traits/trait.py
129 130 131 132 133 134 135 136 137 138 139 140 | |
UpgradableTraitError
Bases: Exception, Generic[T]
Upgradable trait version exception.
This exception is raised when the trait can upgrade existing data meant for older versions of the trait. It must implement an upgrade method that will take old trait data as an argument to handle the upgrade.
Source code in client/ayon_core/pipeline/traits/trait.py
100 101 102 103 104 105 106 107 108 109 | |