added doc strings to librefit and cleaned refit.py

This commit is contained in:
2025-10-12 19:45:07 +02:00
parent 2ad1d32fcc
commit 16aba4c60f
2 changed files with 82 additions and 23 deletions

View File

@@ -153,15 +153,30 @@ def get_current_path(path) -> str:
sys.exit(1)
def create_linear_directories(input_path, target_depth, current_depth, name):
"""Creates the linear directories for the x*y pattern"""
def create_linear_directories(
input_path: str, target_depth: int, current_depth: int, name
):
"""Creates the linear directories for the x*y pattern
If no name is given the name of the level is defaulted to 'level'.
Otherwise it takes the second input of the --name argument. In the
end it appends the number of the folder.
Args:
input_path ( str ): _The current working directory.
target_depth ( int ): _The depth on how deepo directories are created._
current_depth ( int ): _The current depth of the folder creation._
name ( list[str] | None ): _The name of the level directories._
"""
# TODO: - add dynamic name input
# - add docstring
# logger.debug(
# f"FUNC: create_linear_directories(entered) VALUES: path='{input_path}', target_depth='{target_depth}', current_depth='{current_depth}'"
# )
# TODO: Find a way on how to specify the type in the function call
# and let the if statement pass.
# Get base directory name
if name is None:
base_name = "level"
else:
@@ -169,39 +184,63 @@ def create_linear_directories(input_path, target_depth, current_depth, name):
if current_depth > target_depth:
return
# Create directory name
directory_name = (
base_name
+ "_"
+ get_standard_name_number(current_depth, get_int_length(target_depth))
)
# Create the path where to create directory
path = os.path.join(input_path, directory_name)
os.mkdir(path)
# Recursive call of itself
create_linear_directories(path, target_depth, current_depth + 1, name)
def create_parallel_directories(input_path, target_depth, width, name):
"""Creates directories after the pattern x*y"""
def create_parallel_directories(input_path: str, target_depth: int, width: int, name):
"""Creates the branches which house the levels.
# 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}', name={name}"
)
As input it takes the input_path and the width from which it creates
the branches of the structure. Afterwards it passes the target_depth
to another function to create the levels of each branch.
If 'None' is passed to the '--name' argument, the default name 'branch'
gets used as base directory name.
Args:
input_path ( str ): _The current working directory.
target_depth ( int ): _The depth on how deepo directories are created._
width ( int ): _The ammount of branches to create._
name ( list[str] | None ): _The name of the level directories._
"""
# logger.debug(
# f"FUNC: create_parallel_directories(entered) VALUES: path='{input_path}', target_depth='{target_depth}', width='{width}', name={name}"
# )
# TODO: Find a way on how to specify the type in the function call
# and let the if statement pass.
# Get base directory name
if name is None:
base_name = "branch"
else:
base_name = name[0]
for i in range(width):
# Create directory name
directory_name = (
base_name + "_" + get_standard_name_number(i, get_int_length(width))
)
# Create the path where to create directory
path = os.path.join(input_path, directory_name)
os.mkdir(path)
# Recursive call of itself
create_linear_directories(
input_path=path,
target_depth=target_depth,