Compare commits

..

3 Commits

Author SHA1 Message Date
f4f5f9bc6b split decider and input_validator 2025-10-02 15:12:04 +02:00
3c1d881de7 cleanup 2025-10-02 15:11:40 +02:00
b4e5694b7b update README 2025-10-02 13:41:46 +02:00
3 changed files with 32 additions and 26 deletions

View File

@@ -8,6 +8,10 @@ Collection of my python scripts and programs. Containing tools to manipulate the
A script which allows the user to execute commands in a temporary A script which allows the user to execute commands in a temporary
directory. directory.
### Wannado´s After execution, all contents within the folder get removed.
- switch between temp file and temp dir
## refit
A file and folder manipulation tool. The aim is to unify various steps from moving to creating and deleting
directories and folder with one tool.

View File

@@ -119,14 +119,16 @@ def get_current_path(path) -> str:
""" """
logger.debug(f"FUNC: get_current_path() MSG: entered function with path = '{path}'") logger.debug(f"FUNC: get_current_path() MSG: entered function with path = '{path}'")
if path is None: if path is None:
# Set the current directory if none is passed with the command.
path = "." path = "."
logger.debug( logger.warning(
f"FUNC: {get_current_path.__name__} MSG: Path now has the value: '{path}'" f"FUNC: {get_current_path.__name__}() MSG: Path now has the value: '{path}'"
) )
return path return path
else: else:
# Here the check for the path to exist takes place
# Checks if the path, entered by the user, exists.
if os.path.exists(path) is True: if os.path.exists(path) is True:
logger.debug( logger.debug(
f"FUNC: {get_current_path.__name__} MSG: Path '{path}' exists, continue...." f"FUNC: {get_current_path.__name__} MSG: Path '{path}' exists, continue...."

View File

@@ -101,22 +101,13 @@ class Refit_Create:
n -= 1 n -= 1
def input_validator(self): def input_validator(self):
logger.debug("FUNC: input_validator()") """Function, which checks if the user input is valid"""
return True # !!!TODO: make the function return true for the check and only continue the decider if the validation check
# passes
def rf_create_decider(self): # Check working directory
"""Coordination of the 'create' sub command""" if self.input is None:
logger.debug("FUNC: rf_create_decider() MSG: Entered decider function") self.input = librefit.get_current_path(self.input)
# !!!ToDo: implement input_validator() logger.info("FUNC: input_validator() MSG: No directory passed to the command, continue with current directory")
if self.input_validator():
logger.debug("yippie")
# if no input is provided, current directory is set to input
logger.debug(f"DEBUG HERE!: type of path is: {type(self.input)}")
self.input = librefit.get_current_path(self.input)
logger.debug(
f"FUNC: rf_create_decider() MSG: successfully retrievd input value: '{self.input}'"
)
# Exit the program if the -n argument is not passed # Exit the program if the -n argument is not passed
if self.n is None: if self.n is None:
@@ -126,6 +117,17 @@ class Refit_Create:
print("Use the '-n' flag for the create command.") print("Use the '-n' flag for the create command.")
sys.exit(1) sys.exit(1)
def rf_create_decider(self):
"""Coordination of the 'create' sub command"""
logger.debug("FUNC: rf_create_decider() MSG: Entered decider function")
# !!!ToDo: implement input_validator()
if self.input_validator():
logger.debug("yippie")
# Exits the program if recursive and filemode flags are set at the same time # Exits the program if recursive and filemode flags are set at the same time
if self.filemode: if self.filemode:
logger.debug("DECISION filemode set, creating files instead of folders") logger.debug("DECISION filemode set, creating files instead of folders")
@@ -135,8 +137,6 @@ class Refit_Create:
logger.error("Recursive and filemode don´t work together.") logger.error("Recursive and filemode don´t work together.")
print("Recursive and filemode don´t work together.") print("Recursive and filemode don´t work together.")
if self.recursive:
print("help")
if self.recursive is None: if self.recursive is None:
self.create_n_folders(self.n, self.input, self.name) self.create_n_folders(self.n, self.input, self.name)