Add project-tools #142
@ -6,7 +6,7 @@ import json
|
|||||||
|
|
||||||
|
|
||||||
def create_path_dict(startpath, max_depth):
|
def create_path_dict(startpath, max_depth):
|
||||||
path_stucture_dict = {}
|
path_structure_dict = {}
|
||||||
start_folder_name = os.path.basename(start_search_path)
|
start_folder_name = os.path.basename(start_search_path)
|
||||||
for root, dirs, files in os.walk(startpath, followlinks=True):
|
for root, dirs, files in os.walk(startpath, followlinks=True):
|
||||||
# We are only interested in the files and folders inside the start path.
|
# We are only interested in the files and folders inside the start path.
|
||||||
@ -16,11 +16,11 @@ def create_path_dict(startpath, max_depth):
|
|||||||
# Therefore, we will stop if we go too deep.
|
# Therefore, we will stop if we go too deep.
|
||||||
# This avoids infinite loops that can happen when we follow symlinks
|
# This avoids infinite loops that can happen when we follow symlinks
|
||||||
if level > max_depth:
|
if level > max_depth:
|
||||||
print("We have gone unexptibly deep in the file structure, stopping...")
|
print("We have gone too deep in the file structure, stopping...")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
# Insert the data into the dictionary
|
# Insert the data into the dictionary
|
||||||
nested_dict = path_stucture_dict
|
nested_dict = path_structure_dict
|
||||||
key_path = cur_path.split(os.sep)
|
key_path = cur_path.split(os.sep)
|
||||||
final_key = key_path[-1]
|
final_key = key_path[-1]
|
||||||
for key in key_path[:-1]:
|
for key in key_path[:-1]:
|
||||||
@ -39,7 +39,7 @@ def create_path_dict(startpath, max_depth):
|
|||||||
|
|
||||||
for f in files:
|
for f in files:
|
||||||
print('{}{}'.format(subindent, f))
|
print('{}{}'.format(subindent, f))
|
||||||
return path_stucture_dict
|
return path_structure_dict
|
||||||
|
|
||||||
|
|
||||||
def check_if_structure_is_consistent(cur_path, path_dict, error_list):
|
def check_if_structure_is_consistent(cur_path, path_dict, error_list):
|
||||||
|
Loading…
Reference in New Issue
Block a user