new decicion logic WIP
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
from logging import log
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
@@ -124,31 +123,35 @@ class Refit_Create:
|
||||
"""Coordination of the 'create' sub command"""
|
||||
logger.debug("FUNC: rf_create_decider() MSG: Entered decider function")
|
||||
|
||||
if self.input is None:
|
||||
self.input = "."
|
||||
logger.info(
|
||||
f"FUNC: rf_create_decider() MSG: Usingsing current directory as input. value={self.input} "
|
||||
)
|
||||
self.input = librefit.get_current_path(self.input)
|
||||
print(self.input)
|
||||
|
||||
logger.critical(self.input)
|
||||
# if self.input is None:
|
||||
# self.input = "."
|
||||
# logger.info(
|
||||
# f"FUNC: rf_create_decider() MSG: Usingsing current directory as input. value={self.input} "
|
||||
# )
|
||||
|
||||
if self.filemode:
|
||||
logger.debug("DECISION if filemode")
|
||||
self.create_n_files(self.n, self.input, self.name)
|
||||
elif self.n is not None and self.recursive is False:
|
||||
logger.debug(
|
||||
f"FUNC: {self.rf_create_decider.__name__} DIR-MODE | ARGS: n={self.n} input={self.input} name={self.name}"
|
||||
)
|
||||
self.create_n_folders(self.n, self.input, self.name)
|
||||
elif self.recursive:
|
||||
logger.error("EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE")
|
||||
logger.debug(f"FUNC: {self.rf_create_decider.__name__}")
|
||||
else:
|
||||
logger.debug(f"FUNC: rf_create_decider() MSG: given arguments: {self.args}")
|
||||
print(
|
||||
"Use '-n' argument to create directories.\nPlease use 'refit create -h' for help"
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
# if self.filemode:
|
||||
# logger.debug("DECISION if filemode")
|
||||
# self.create_n_files(self.n, self.input, self.name)
|
||||
|
||||
|
||||
# if self.recursive is False:
|
||||
# logger.debug(
|
||||
# f"FUNC: {self.rf_create_decider.__name__} DIR-MODE | ARGS: n={self.n} input={self.input} name={self.name}"
|
||||
# )
|
||||
# if self.n is not None: self.create_n_folders(self.n, self.input, self.name)
|
||||
# else:
|
||||
# ERROR_MESSAGE="Please input the number on how many objects you want to create"
|
||||
|
||||
# else:
|
||||
# logger.debug(f"FUNC: rf_create_decider() MSG: given arguments: {self.args}")
|
||||
# print(
|
||||
# "Use '-n' argument to create directories.\nPlease use 'refit create -h' for help"
|
||||
# )
|
||||
# sys.exit(1)
|
||||
|
||||
def __call__(self):
|
||||
"""Gets called when the 'create' subcommand is used."""
|
||||
|
||||
Reference in New Issue
Block a user