mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merge pull request #1813 from pypeclub/bugfix/1793_project_folder_structure_overrides
Project folder structure overrides
This commit is contained in:
commit
020904df20
5 changed files with 36 additions and 23 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
import re
|
||||
import json
|
||||
|
||||
from openpype.modules.ftrack.lib import BaseAction, statics_icon
|
||||
from openpype.api import Anatomy, get_project_settings
|
||||
|
|
@ -84,6 +85,9 @@ class CreateProjectFolders(BaseAction):
|
|||
}
|
||||
|
||||
try:
|
||||
if isinstance(project_folder_structure, str):
|
||||
project_folder_structure = json.loads(project_folder_structure)
|
||||
|
||||
# Get paths based on presets
|
||||
basic_paths = self.get_path_items(project_folder_structure)
|
||||
self.create_folders(basic_paths, project_entity)
|
||||
|
|
|
|||
|
|
@ -277,28 +277,7 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"project_folder_structure": {
|
||||
"__project_root__": {
|
||||
"prod": {},
|
||||
"resources": {
|
||||
"footage": {
|
||||
"plates": {},
|
||||
"offline": {}
|
||||
},
|
||||
"audio": {},
|
||||
"art_dept": {}
|
||||
},
|
||||
"editorial": {},
|
||||
"assets[ftrack.Library]": {
|
||||
"characters[ftrack]": {},
|
||||
"locations[ftrack]": {}
|
||||
},
|
||||
"shots[ftrack.Sequence]": {
|
||||
"scripts": {},
|
||||
"editorial[ftrack.Folder]": {}
|
||||
}
|
||||
}
|
||||
},
|
||||
"project_folder_structure": "{\"__project_root__\": {\"prod\": {}, \"resources\": {\"footage\": {\"plates\": {}, \"offline\": {}}, \"audio\": {}, \"art_dept\": {}}, \"editorial\": {}, \"assets[ftrack.Library]\": {\"characters[ftrack]\": {}, \"locations[ftrack]\": {}}, \"shots[ftrack.Sequence]\": {\"scripts\": {}, \"editorial[ftrack.Folder]\": {}}}}",
|
||||
"sync_server": {
|
||||
"enabled": true,
|
||||
"config": {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import re
|
||||
import copy
|
||||
import json
|
||||
from abc import abstractmethod
|
||||
|
||||
from .base_entity import ItemEntity
|
||||
|
|
@ -440,6 +441,7 @@ class RawJsonEntity(InputEntity):
|
|||
|
||||
def _item_initalization(self):
|
||||
# Schema must define if valid value is dict or list
|
||||
store_as_string = self.schema_data.get("store_as_string", False)
|
||||
is_list = self.schema_data.get("is_list", False)
|
||||
if is_list:
|
||||
valid_value_types = (list, )
|
||||
|
|
@ -448,6 +450,8 @@ class RawJsonEntity(InputEntity):
|
|||
valid_value_types = (dict, )
|
||||
value_on_not_set = {}
|
||||
|
||||
self.store_as_string = store_as_string
|
||||
|
||||
self._is_list = is_list
|
||||
self.valid_value_types = valid_value_types
|
||||
self.value_on_not_set = value_on_not_set
|
||||
|
|
@ -491,6 +495,23 @@ class RawJsonEntity(InputEntity):
|
|||
result = self.metadata != self._metadata_for_current_state()
|
||||
return result
|
||||
|
||||
def schema_validations(self):
|
||||
if self.store_as_string and self.is_env_group:
|
||||
reason = (
|
||||
"RawJson entity can't store environment group metadata"
|
||||
" as string."
|
||||
)
|
||||
raise EntitySchemaError(self, reason)
|
||||
super(RawJsonEntity, self).schema_validations()
|
||||
|
||||
def _convert_to_valid_type(self, value):
|
||||
if isinstance(value, STRING_TYPE):
|
||||
try:
|
||||
return json.loads(value)
|
||||
except Exception:
|
||||
pass
|
||||
return super(RawJsonEntity, self)._convert_to_valid_type(value)
|
||||
|
||||
def _metadata_for_current_state(self):
|
||||
if (
|
||||
self._override_state is OverrideState.PROJECT
|
||||
|
|
@ -510,6 +531,9 @@ class RawJsonEntity(InputEntity):
|
|||
value = super(RawJsonEntity, self)._settings_value()
|
||||
if self.is_env_group and isinstance(value, dict):
|
||||
value.update(self.metadata)
|
||||
|
||||
if self.store_as_string:
|
||||
return json.dumps(value)
|
||||
return value
|
||||
|
||||
def _prepare_value(self, value):
|
||||
|
|
|
|||
|
|
@ -337,6 +337,11 @@ How output of the schema could look like on save:
|
|||
- schema also defines valid value type
|
||||
- by default it is dictionary
|
||||
- to be able use list it is required to define `is_list` to `true`
|
||||
- output can be stored as string
|
||||
- this is to allow any keys in dictionary
|
||||
- set key `store_as_string` to `true`
|
||||
- code using that setting must expected that value is string and use json module to convert it to python types
|
||||
|
||||
```
|
||||
{
|
||||
"type": "raw-json",
|
||||
|
|
|
|||
|
|
@ -17,7 +17,8 @@
|
|||
"type": "raw-json",
|
||||
"label": "Project Folder Structure",
|
||||
"key": "project_folder_structure",
|
||||
"use_label_wrap": true
|
||||
"use_label_wrap": true,
|
||||
"store_as_string": true
|
||||
},
|
||||
{
|
||||
"type": "schema",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue