Add project-tools #142
@ -41,23 +41,22 @@ def create_path_dict(startpath, max_depth):
|
||||
return path_stucture_dict
|
||||
|
||||
|
||||
def check_if_structure_is_consistent(start_path, path_dict, error_list):
|
||||
for key in path_dict:
|
||||
cur_path = str(start_path) + os.sep + key
|
||||
print("Checking path: " + cur_path)
|
||||
if os.path.exists(cur_path):
|
||||
nested_item = path_dict[key]
|
||||
def check_if_structure_is_consistent(cur_path, path_dict, error_list):
|
||||
for path in path_dict:
|
||||
# Get next path to check for consistency
|
||||
next_path = (cur_path / path).resolve()
|
||||
print("Checking path: %s" % next_path)
|
||||
if next_path.exists():
|
||||
nested_item = path_dict[path]
|
||||
if type(nested_item) is not dict:
|
||||
if os.path.isfile(cur_path):
|
||||
if next_path.is_file():
|
||||
continue
|
||||
else:
|
||||
# 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: " + cur_path + " is not a file, when it should be!"]
|
||||
check_if_structure_is_consistent(cur_path, nested_item, error_list)
|
||||
error_list += ["ERROR: %s is not a file, when it should be!" % next_path]
|
||||
check_if_structure_is_consistent(next_path, nested_item, error_list)
|
||||
else:
|
||||
# print("ERROR: " + cur_path + " doesn't exist!")
|
||||
error_list += ["ERROR: " + cur_path + " doesn't exist!"]
|
||||
error_list += ["ERROR: %s doesn't exist!" % next_path]
|
||||
|
||||
|
||||
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 pre-generated. This is the stucture the consistency check will ensure is there
|
||||
# TODO don't record or check the projects name.
|
||||
path_dict = {
|
||||
'pets': {
|
||||
'../../../': {
|
||||
'shared': {'artifacts': {}},
|
||||
'svn': {'tools': {'consistency_check.py': 'file'}},
|
||||
'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
|
||||
|
||||
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()
|
||||
if len(error_list) == 0:
|
||||
|
Loading…
Reference in New Issue
Block a user