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

View File

@@ -106,11 +106,10 @@ class Refit_Create:
f"FUNC: create_recursive(beginning) MSG: entered function with following arguments: recursive='{recursive}' name='{name}' input='{input}' n='{n}'" f"FUNC: create_recursive(beginning) MSG: entered function with following arguments: recursive='{recursive}' name='{name}' input='{input}' n='{n}'"
) )
librefit.create_recursive_folders( librefit.create_recursive_folders(
input, input_path=input,
recursive[0], target_depth=recursive[0],
0, current_depth=0,
recursive[1], width=recursive[1],
0,
) )
def input_validator(self): def input_validator(self):