fixed recursion

This commit is contained in:
2025-10-04 09:09:02 +02:00
parent acd3f5fe39
commit 9d2d6931e3
2 changed files with 19 additions and 21 deletions

View File

@@ -145,35 +145,34 @@ def get_current_path(path) -> str:
sys.exit(1)
# FIXME: th function needs some attention
# TODO:
# - add proper debugging
# - make it walk down one directory.
def create_recursive_folders(
input_path, target_depth, current_depth, width, curret_width
):
# FIXME: the assigning of the number to the folders is not working
# TODO: - add logging
# - add docstring
def create_recursive_folders(input_path, target_depth, current_depth, width):
"""Creates a recursive directory structure with y as depth and x as width"""
if current_depth == target_depth:
sys.exit(1)
# length_width = str(len(width))
if current_depth >= target_depth:
return
length_width = len(str(width))
logger.debug(
f"FUNC: create_recursive_folders(length_width) MSG: length_width='{length_width}'"
)
while curret_width < width:
# TODO: fix the issue, that the number gets appended to an existing number
new_directory_name = "sub_dir" + get_standard_name_number(length_width, width)
for i in range(width):
folder_index = i + 1
new_directory_name = "sub_dir" + get_standard_name_number(
length_width, folder_index
)
new_directory_path = os.path.join(input_path, new_directory_name)
print(new_directory_path)
curret_width += 1
logger.debug(f"New Path: path={new_directory_path}")
create_recursive_folders(
new_directory_path,
target_depth,
width,
current_depth + 1,
curret_width,
width,
)