1
+ from __future__ import annotations
1
2
import os
2
3
import re
3
4
import json
5
+ from typing import Any , Union
4
6
5
7
from ayon_core .settings import get_project_settings
6
8
from ayon_core .lib import Logger
9
11
from .template_data import get_project_template_data
10
12
11
13
12
- def concatenate_splitted_paths (split_paths , anatomy ):
14
+ def concatenate_splitted_paths (split_paths , anatomy : Anatomy ):
13
15
log = Logger .get_logger ("concatenate_splitted_paths" )
14
16
pattern_array = re .compile (r"\[.*\]" )
15
17
output = []
@@ -47,7 +49,7 @@ def concatenate_splitted_paths(split_paths, anatomy):
47
49
return output
48
50
49
51
50
- def fill_paths (path_list , anatomy ):
52
+ def fill_paths (path_list : list [ str ] , anatomy : Anatomy ):
51
53
format_data = get_project_template_data (project_name = anatomy .project_name )
52
54
format_data ["root" ] = anatomy .roots
53
55
filled_paths = []
@@ -59,7 +61,7 @@ def fill_paths(path_list, anatomy):
59
61
return filled_paths
60
62
61
63
62
- def create_project_folders (project_name , basic_paths = None ):
64
+ def create_project_folders (project_name : str , basic_paths = None ):
63
65
log = Logger .get_logger ("create_project_folders" )
64
66
anatomy = Anatomy (project_name )
65
67
if basic_paths is None :
@@ -80,8 +82,19 @@ def create_project_folders(project_name, basic_paths=None):
80
82
os .makedirs (path )
81
83
82
84
83
- def _list_path_items (folder_structure ):
85
+ def _list_path_items (
86
+ folder_structure : Union [dict [str , Any ], list [str ]]):
84
87
output = []
88
+
89
+ # Allow leaf folders of the `project_folder_structure` to use a list of
90
+ # strings instead of a dictionary of keys with empty values.
91
+ if isinstance (folder_structure , list ):
92
+ if not all (isinstance (item , str ) for item in folder_structure ):
93
+ raise ValueError (
94
+ f"List items must all be strings. Got: { folder_structure } " )
95
+ return [[path ] for path in folder_structure ]
96
+
97
+ # Process key, value as key for folder names and value its subfolders
85
98
for key , value in folder_structure .items ():
86
99
if not value :
87
100
output .append (key )
@@ -99,7 +112,7 @@ def _list_path_items(folder_structure):
99
112
return output
100
113
101
114
102
- def get_project_basic_paths (project_name ):
115
+ def get_project_basic_paths (project_name : str ):
103
116
project_settings = get_project_settings (project_name )
104
117
folder_structure = (
105
118
project_settings ["core" ]["project_folder_structure" ]
0 commit comments