Add project-tools #142
@ -41,23 +41,22 @@ def create_path_dict(startpath, max_depth):
|
|||||||
return path_stucture_dict
|
return path_stucture_dict
|
||||||
|
|
||||||
|
|
||||||
def check_if_structure_is_consistent(start_path, path_dict, error_list):
|
def check_if_structure_is_consistent(cur_path, path_dict, error_list):
|
||||||
for key in path_dict:
|
for path in path_dict:
|
||||||
cur_path = str(start_path) + os.sep + key
|
# Get next path to check for consistency
|
||||||
print("Checking path: " + cur_path)
|
next_path = (cur_path / path).resolve()
|
||||||
if os.path.exists(cur_path):
|
print("Checking path: %s" % next_path)
|
||||||
nested_item = path_dict[key]
|
if next_path.exists():
|
||||||
|
nested_item = path_dict[path]
|
||||||
if type(nested_item) is not dict:
|
if type(nested_item) is not dict:
|
||||||
if os.path.isfile(cur_path):
|
if next_path.is_file():
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
# This must be a file, warn if it is not
|
# This must be a file, warn if it is not
|
||||||
# print("ERROR: " + cur_path + " is not a file, when it should be!")
|
error_list += ["ERROR: %s is not a file, when it should be!" % next_path]
|
||||||
error_list += ["ERROR: " + cur_path + " is not a file, when it should be!"]
|
check_if_structure_is_consistent(next_path, nested_item, error_list)
|
||||||
check_if_structure_is_consistent(cur_path, nested_item, error_list)
|
|
||||||
else:
|
else:
|
||||||
# print("ERROR: " + cur_path + " doesn't exist!")
|
error_list += ["ERROR: %s doesn't exist!" % next_path]
|
||||||
error_list += ["ERROR: " + cur_path + " doesn't exist!"]
|
|
||||||
|
|
||||||
|
|
||||||
current_file_path = pathlib.Path(__file__)
|
current_file_path = pathlib.Path(__file__)
|
||||||
@ -65,9 +64,8 @@ start_search_path = current_file_path.parent.parent.parent.resolve()
|
|||||||
# path_dict = create_path_dict(str(start_search_path), 5)
|
# path_dict = create_path_dict(str(start_search_path), 5)
|
||||||
|
|
||||||
# path_dict pre-generated. This is the stucture the consistency check will ensure is there
|
# path_dict pre-generated. This is the stucture the consistency check will ensure is there
|
||||||
# TODO don't record or check the projects name.
|
|
||||||
path_dict = {
|
path_dict = {
|
||||||
'pets': {
|
'../../../': {
|
||||||
'shared': {'artifacts': {}},
|
'shared': {'artifacts': {}},
|
||||||
'svn': {'tools': {'consistency_check.py': 'file'}},
|
'svn': {'tools': {'consistency_check.py': 'file'}},
|
||||||
'local': {'blender': {}, 'scripts': {}, 'config': {}},
|
'local': {'blender': {}, 'scripts': {}, 'config': {}},
|
||||||
@ -76,7 +74,7 @@ path_dict = {
|
|||||||
# TODO perhaps make a function to pretty print out the path_dict for easier inspection
|
# TODO perhaps make a function to pretty print out the path_dict for easier inspection
|
||||||
|
|
||||||
error_list = []
|
error_list = []
|
||||||
check_if_structure_is_consistent(start_search_path.parent, path_dict, error_list)
|
check_if_structure_is_consistent(current_file_path, path_dict, error_list)
|
||||||
|
|
||||||
print()
|
print()
|
||||||
if len(error_list) == 0:
|
if len(error_list) == 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user