env_tools
CycleError
Bases: ValueError
Raised when a cycle is detected in dynamic env variables compute.
Source code in client/ayon_core/lib/env_tools.py
17 18 19 |
|
DynamicKeyClashError
Bases: Exception
Raised when dynamic key clashes with an existing key.
Source code in client/ayon_core/lib/env_tools.py
22 23 24 |
|
compute_env_variables_structure(env, fill_dynamic_keys=True)
Compute the result from recursive dynamic environment.
Keys that are not present in the data will remain unformatted as the
original keys. So they can be formatted against the current user environment when merging. So {"A": "{key}"} will remain {key} if not present in the dynamic environment.
Source code in client/ayon_core/lib/env_tools.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
env_value_to_bool(env_key=None, value=None, default=False)
Convert environment variable value to boolean.
Function is based on value of the environemt variable. Value is lowered so function is not case sensitive.
Returns:
Name | Type | Description |
---|---|---|
bool | bool | If value match to one of ["true", "yes", "1"] result if True but if value match to ["false", "no", "0"] result is False else default value is returned. |
Source code in client/ayon_core/lib/env_tools.py
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 |
|
get_paths_from_environ(env_key=None, env_value=None, return_first=False)
Return existing paths from specific environment variable.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env_key | Optional[str] | Environment key where should look for paths. | None |
env_value | Optional[str] | Value of environment variable. Argument | None |
return_first | bool | Return first found value or return list of found paths. | False |
Returns:
Type | Description |
---|---|
Optional[Union[str, list[str]]] | Optional[Union[str, list[str]]]: Result of found path/s. |
Source code in client/ayon_core/lib/env_tools.py
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 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
merge_env_variables(src_env, dst_env, missing_template=None)
Merge the tools environment with the 'current_env'.
This finalizes the join with a current environment by formatting the remainder of dynamic variables with that from the current environment.
Remaining missing variables result in an empty value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
src_env | dict | The dynamic environment | required |
dst_env | dict | The target environment variables mapping to merge the dynamic environment into. | required |
missing_template | str | Argument passed to '_partial_format' during merging. | None |
Returns:
Type | Description |
---|---|
dict[str, str] | dict[str, str]: The resulting environment after the merge. |
Source code in client/ayon_core/lib/env_tools.py
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
|
parse_env_variables_structure(env, platform_name=None)
Parse environment for platform-specific values and paths as lists.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env | dict | The source environment to read. | required |
platform_name | Optional[PlatformName] | Name of platform to parse for. Defaults to current platform. | None |
Returns:
Name | Type | Description |
---|---|---|
dict | dict[str, str] | The flattened environment for a platform. |
Source code in client/ayon_core/lib/env_tools.py
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 |
|