added custom naming to recursion and fixed naming in filemode
This commit is contained in:
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user