diff --git a/refit/src/modules/librefit.py b/refit/src/modules/librefit.py index c1abb8c..26db68e 100644 --- a/refit/src/modules/librefit.py +++ b/refit/src/modules/librefit.py @@ -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, ) diff --git a/refit/src/modules/refit_create.py b/refit/src/modules/refit_create.py index ff30a55..72bfa32 100644 --- a/refit/src/modules/refit_create.py +++ b/refit/src/modules/refit_create.py @@ -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}'" ) librefit.create_recursive_folders( - input, - recursive[0], - 0, - recursive[1], - 0, + input_path=input, + target_depth=recursive[0], + current_depth=0, + width=recursive[1], ) def input_validator(self):