mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
create project structure will work as before for all roots
This commit is contained in:
parent
7a91ec8dce
commit
4822fc88bc
1 changed files with 28 additions and 16 deletions
|
|
@ -32,11 +32,22 @@ class CreateProjectFolders(BaseAction):
|
||||||
def launch(self, session, entities, event):
|
def launch(self, session, entities, event):
|
||||||
entity = entities[0]
|
entity = entities[0]
|
||||||
project = self.get_project_from_entity(entity)
|
project = self.get_project_from_entity(entity)
|
||||||
presets = config.get_presets()["tools"]["project_folder_structure"]
|
project_folder_presets = (
|
||||||
|
config.get_presets()
|
||||||
|
.get("tools", {})
|
||||||
|
.get("project_folder_structure")
|
||||||
|
)
|
||||||
|
if not project_folder_presets:
|
||||||
|
return {
|
||||||
|
"success": False,
|
||||||
|
"message": "Project structure presets are not set."
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Get paths based on presets
|
# Get paths based on presets
|
||||||
basic_paths = self.get_path_items(presets)
|
basic_paths = self.get_path_items(project_folder_presets)
|
||||||
self.create_folders(basic_paths, entity)
|
anatomy = Anatomy(project["full_name"])
|
||||||
|
self.create_folders(basic_paths, entity, project, anatomy)
|
||||||
self.create_ftrack_entities(basic_paths, project)
|
self.create_ftrack_entities(basic_paths, project)
|
||||||
|
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
|
|
@ -169,21 +180,22 @@ class CreateProjectFolders(BaseAction):
|
||||||
output.append(os.path.normpath(os.path.sep.join(clean_items)))
|
output.append(os.path.normpath(os.path.sep.join(clean_items)))
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def create_folders(self, basic_paths, entity):
|
def create_folders(self, basic_paths, entity, project, anatomy):
|
||||||
# Set project root folder
|
roots_paths = []
|
||||||
if entity.entity_type.lower() == 'project':
|
if isinstance(anatomy.roots, dict):
|
||||||
project_name = entity['full_name']
|
for root in anatomy.roots:
|
||||||
|
roots_paths.append(root.value)
|
||||||
else:
|
else:
|
||||||
project_name = entity['project']['full_name']
|
roots_paths.append(anatomy.roots.value)
|
||||||
project_root_items = [os.environ['AVALON_PROJECTS'], project_name]
|
|
||||||
project_root = os.path.sep.join(project_root_items)
|
|
||||||
|
|
||||||
full_paths = self.compute_paths(basic_paths, project_root)
|
for root_path in roots_paths:
|
||||||
# Create folders
|
project_root = os.path.join(root_path, project["full_name"])
|
||||||
for path in full_paths:
|
full_paths = self.compute_paths(basic_paths, project_root)
|
||||||
if os.path.exists(path):
|
# Create folders
|
||||||
continue
|
for path in full_paths:
|
||||||
os.makedirs(path.format(project_root=project_root))
|
if os.path.exists(path):
|
||||||
|
continue
|
||||||
|
os.makedirs(path.format(project_root=project_root))
|
||||||
|
|
||||||
|
|
||||||
def register(session, plugins_presets={}):
|
def register(session, plugins_presets={}):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue