2025-09-28 17:19:20 +02:00
|
|
|
from .refit_logger import logger
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_standard_name_number(current_number, number_str_length):
|
|
|
|
|
"""returns a number string filled to the length of the input number"""
|
2025-09-29 21:38:42 +02:00
|
|
|
# logger.debug(
|
|
|
|
|
# f"FUNC: get_standard_name_number() index={current_number} string_length={number_str_length}"
|
|
|
|
|
# )
|
2025-09-28 17:19:20 +02:00
|
|
|
current_number = str(current_number)
|
|
|
|
|
standard_name_number = str.zfill(current_number, number_str_length)
|
2025-09-29 21:38:42 +02:00
|
|
|
# logger.debug(
|
|
|
|
|
# f"FUNC: get_standard_name_number() return value= '{standard_name_number}'"
|
|
|
|
|
# )
|
2025-09-28 17:19:20 +02:00
|
|
|
return standard_name_number
|
|
|
|
|
|
|
|
|
|
|
2025-09-30 09:35:25 +02:00
|
|
|
def get_standard_folder_name(name) -> str:
|
|
|
|
|
"""Takes the --name argument as input and returns an default value if no name is provided
|
|
|
|
|
or takes the first element of the list, passed to the argument.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Example:
|
|
|
|
|
None -> .
|
|
|
|
|
["directory"] -> dirctory
|
|
|
|
|
["folder", "directory"] -> folder
|
|
|
|
|
|
|
|
|
|
Returns str
|
|
|
|
|
"""
|
2025-09-28 17:19:20 +02:00
|
|
|
logger.debug("get_standard_folder_name() call")
|
|
|
|
|
if name is None:
|
|
|
|
|
standard_folder_name = "directory"
|
2025-09-29 20:11:16 +02:00
|
|
|
logger.info(
|
|
|
|
|
f"No name for folder assigned, continue with default value '{standard_folder_name}'."
|
|
|
|
|
)
|
2025-09-28 17:19:20 +02:00
|
|
|
else:
|
2025-09-29 20:11:16 +02:00
|
|
|
logger.debug(
|
|
|
|
|
f"FUNC: get_standard_folder_name() Properties of name='{name}': Type: {type(name)}, Length: {len(name)}"
|
|
|
|
|
)
|
2025-09-28 17:19:20 +02:00
|
|
|
|
|
|
|
|
# Checks if multiple names are passed to the --name argument
|
|
|
|
|
# if so, only the first one gets used.
|
|
|
|
|
if len(name) > 1:
|
|
|
|
|
_NAMES_WARNING = f"{len(name)} names given, only one required.\nContinuing with '{name[0]}' as name."
|
2025-09-29 20:11:16 +02:00
|
|
|
logger.warning("FUNC: get_standard_folder_name()" + _NAMES_WARNING)
|
2025-09-28 17:19:20 +02:00
|
|
|
print(_NAMES_WARNING)
|
|
|
|
|
standard_folder_name = name[0]
|
|
|
|
|
|
2025-09-29 20:11:16 +02:00
|
|
|
logger.debug(
|
|
|
|
|
f"FUNC: get_standard_folder_name() Properties of folder name '{standard_folder_name}': Type: {type(standard_folder_name)}"
|
|
|
|
|
)
|
2025-09-28 17:19:20 +02:00
|
|
|
else:
|
|
|
|
|
standard_folder_name = name[0]
|
|
|
|
|
logger.debug("Continuing with expected input")
|
2025-09-29 20:11:16 +02:00
|
|
|
logger.debug("FUNC: get_standard_folder_name() exit.")
|
2025-09-28 17:19:20 +02:00
|
|
|
return standard_folder_name
|
2025-09-29 15:36:18 +02:00
|
|
|
|
2025-09-29 20:11:16 +02:00
|
|
|
|
2025-09-30 09:35:25 +02:00
|
|
|
def get_standard_file_name(name) -> str:
|
|
|
|
|
"""Returnes a name either from a list or the default value.
|
|
|
|
|
|
|
|
|
|
This function sanitizes the input, which gets passed as a list or None from
|
|
|
|
|
argparse. The function either chooses the first entry of the list, given to
|
|
|
|
|
the --name argument or returns the default value 'file'
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
name (list[str] | None): A list of names if passed to the --name argument
|
|
|
|
|
or None if no name is passed.
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
str: The file name. Returns 'file' as default value if name argument is 'None'
|
|
|
|
|
otherwise the first element of the list.
|
|
|
|
|
|
|
|
|
|
Examples:
|
|
|
|
|
>>> get_standard_file_name(None)
|
|
|
|
|
'file'
|
|
|
|
|
>>> get_standard_file_name(["example"])
|
|
|
|
|
'example'
|
|
|
|
|
>>> get_standard_file_name(["file_name", "example"])
|
|
|
|
|
'file_name'
|
|
|
|
|
"""
|
2025-09-29 20:11:16 +02:00
|
|
|
|
2025-09-30 09:35:25 +02:00
|
|
|
logger.debug(f"FUNC: get_standard_file_name() MSG: entered function with name='{name}'")
|
|
|
|
|
standard_file_name = name[0] if name is not None else "file"
|
|
|
|
|
logger.debug(f"FUNC: get_standard_file_name MSG: Continuing with expected input: '{standard_file_name}'")
|
2025-09-29 20:11:16 +02:00
|
|
|
|
|
|
|
|
logger.debug("FUNC get_standard_file_name() MSG: Exit")
|
2025-09-29 15:36:18 +02:00
|
|
|
return standard_file_name
|