added custom naming to recursion and fixed naming in filemode

This commit is contained in:
2025-10-05 15:58:36 +02:00
parent 46ea1db65d
commit 9c39b773da
5 changed files with 40 additions and 36 deletions

View File

@@ -153,7 +153,7 @@ def get_current_path(path) -> str:
sys.exit(1)
def create_linear_directories(input_path, target_depth, current_depth):
def create_linear_directories(input_path, target_depth, current_depth, name):
"""Creates the linear directories for the x*y pattern"""
# TODO: - add dynamic name input
@@ -162,40 +162,49 @@ def create_linear_directories(input_path, target_depth, current_depth):
# f"FUNC: create_linear_directories(entered) VALUES: path='{input_path}', target_depth='{target_depth}', current_depth='{current_depth}'"
# )
if name is None:
base_name = "level"
else:
base_name = name[1]
if current_depth > target_depth:
return
directory_name = "level_" + get_standard_name_number(
current_depth,
get_int_length(target_depth),
directory_name = (
base_name
+ "_"
+ get_standard_name_number(current_depth, get_int_length(target_depth))
)
path = os.path.join(input_path, directory_name)
os.mkdir(path)
create_linear_directories(
path,
target_depth,
current_depth + 1,
)
create_linear_directories(path, target_depth, current_depth + 1, name)
def create_parallel_directories(input_path, target_depth, width):
def create_parallel_directories(input_path, target_depth, width, name):
"""Creates directories after the pattern x*y"""
# TODO: - add dynamic name input
# - add docstring
# logger.debug(
# f"FUNC: create_parallel_directories(entered) VALUES: path='{input_path}', target_depth='{target_depth}', width='{width}'"
# )
logger.debug(
f"FUNC: create_parallel_directories(entered) VALUES: path='{input_path}', target_depth='{target_depth}', width='{width}', name={name}"
)
if name is None:
base_name = "branch"
else:
base_name = name[0]
for i in range(width):
directory_name = "branch_" + get_standard_name_number(i, get_int_length(width))
directory_name = (
base_name + "_" + get_standard_name_number(i, get_int_length(width))
)
path = os.path.join(input_path, directory_name)
os.mkdir(path)
create_linear_directories(
path,
target_depth,
input_path=path,
target_depth=target_depth,
current_depth=0,
name=name,
)