diff --git a/refit/README.md b/refit/README.md index e1bb62f..c059108 100644 --- a/refit/README.md +++ b/refit/README.md @@ -25,6 +25,8 @@ n -> valid input check back for no arguments passed? ## Changelog +<2025-10-04> V0.3.4 - Added recursive directory creation and fixed +numbered naming <2025-10-03> V0.3.3 - Added the beginning of recursive mode <2025-09-30> V0.3.2 - Refactoring librefit and added proper docstrings; begun to remove the check for the valid input and put it in the decider diff --git a/refit/src/modules/librefit.py b/refit/src/modules/librefit.py index 26db68e..3ec70f9 100644 --- a/refit/src/modules/librefit.py +++ b/refit/src/modules/librefit.py @@ -24,14 +24,14 @@ def get_standard_name_number(current_number: int, number_str_length: int) -> str >>> get_standard_name_number(23, 4) '0023' """ - # logger.debug( - # f"FUNC: get_standard_name_number() index={current_number} string_length={number_str_length}" - # ) + logger.debug( + f"FUNC: get_standard_name_number() index={current_number} string_length={number_str_length}" + ) temp_current_number = str(current_number) standard_name_number = str.zfill(temp_current_number, number_str_length) - # logger.debug( - # f"FUNC: get_standard_name_number() return value= '{standard_name_number}'" - # ) + logger.debug( + f"FUNC: get_standard_name_number() return value= '{standard_name_number}'" + ) return standard_name_number @@ -151,20 +151,25 @@ def get_current_path(path) -> str: def create_recursive_folders(input_path, target_depth, current_depth, width): """Creates a recursive directory structure with y as depth and x as width""" + # Exits the recursion if the target depth is reached. if current_depth >= target_depth: return + # Getting the lenth of the number string which gets added to the dir name. length_width = len(str(width)) logger.debug( - f"FUNC: create_recursive_folders(length_width) MSG: length_width='{length_width}'" + f"FUNC: create_recursive_folders(length_width) MSG: given values: path={input_path} target_depth={target_depth} current_depth={current_depth}, with={width}" ) + # Creates the directories of the current depth for i in range(width): + # Getting the numbering of the folder. folder_index = i + 1 new_directory_name = "sub_dir" + get_standard_name_number( - length_width, folder_index + folder_index, length_width ) new_directory_path = os.path.join(input_path, new_directory_name) + os.mkdir(new_directory_path) print(new_directory_path) logger.debug(f"New Path: path={new_directory_path}") @@ -174,6 +179,3 @@ def create_recursive_folders(input_path, target_depth, current_depth, width): current_depth + 1, width, ) - - -# create_recursive_folders(".", 2, 0, 3) diff --git a/refit/src/version.cfg b/refit/src/version.cfg index 0517c75..bbaa445 100644 --- a/refit/src/version.cfg +++ b/refit/src/version.cfg @@ -1,5 +1,5 @@ [VERSION] major = 0 minor = 3 -patch = 3 +patch = 4