new decicion logic WIP

This commit is contained in:
2025-10-01 16:07:08 +02:00
parent caff94ab41
commit 461533b717
2 changed files with 61 additions and 24 deletions

View File

@@ -1,3 +1,6 @@
import os
import sys
from .refit_logger import logger
@@ -99,3 +102,34 @@ def get_standard_file_name(name) -> str:
logger.debug("FUNC get_standard_file_name() MSG: Exit")
return standard_file_name
def get_current_path(path: str) -> str:
"""Checks if the path argument is emty and applies the current directory as working path.
This function takes an list with strings as an input. If the input is `None` the current
directory is taken as the working directory.
If the path is passed, a check for its existence takes place.
Args:
path (str): _The current working directory._
Returns:
str: _Returns the path of the current directory after check for existence_
"""
if path is None:
path = "."
logger.debug(f"FUNC: {get_current_path.__name__} MSG: Path now has the value: '{path}'")
return path
else:
# Here the check for the path to exist takes place
if os.path.exists(path) is True:
logger.debug(f"FUNC: {get_current_path.__name__} MSG: Path '{path}' exists, continue....")
return path
else:
ERROR_MESSAGE = f"FUNC: {get_current_path.__name__} MSG: '{path}' is no valid path."
logger.error(ERROR_MESSAGE)
print(ERROR_MESSAGE)
sys.exit(1)