modified .gitignore

This commit is contained in:
2025-10-01 22:20:23 +02:00
parent 461533b717
commit 691b68cb4c
5 changed files with 61 additions and 57 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
releases releases
version.py version.py
tester
# ---> Python # ---> Python
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files

View File

@@ -18,6 +18,7 @@
- rework rf_create_decider() so it does not execute if no inputs are given -> valid input check back for no arguments passed? - rework rf_create_decider() so it does not execute if no inputs are given -> valid input check back for no arguments passed?
- check done in rf_create_decider() - check done in rf_create_decider()
- get rid of input argument, default to current directory and and make it positional - get rid of input argument, default to current directory and and make it positional
- implement back in the valid input check
# Changelog # Changelog

View File

@@ -104,7 +104,7 @@ def get_standard_file_name(name) -> str:
return standard_file_name return standard_file_name
def get_current_path(path: str) -> str: def get_current_path(path) -> str:
"""Checks if the path argument is emty and applies the current directory as working path. """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 This function takes an list with strings as an input. If the input is `None` the current
@@ -117,19 +117,25 @@ def get_current_path(path: str) -> str:
Returns: Returns:
str: _Returns the path of the current directory after check for existence_ str: _Returns the path of the current directory after check for existence_
""" """
logger.debug(f"FUNC: get_current_path() MSG: entered function with path = '{path}'")
if path is None: if path is None:
path = "." path = "."
logger.debug(f"FUNC: {get_current_path.__name__} MSG: Path now has the value: '{path}'") logger.debug(
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 # Here the check for the path to exist takes place
if os.path.exists(path) is True: if os.path.exists(path) is True:
logger.debug(f"FUNC: {get_current_path.__name__} MSG: Path '{path}' exists, continue....") logger.debug(
f"FUNC: {get_current_path.__name__} MSG: Path '{path}' exists, continue...."
)
return path return path
else: else:
ERROR_MESSAGE = f"FUNC: {get_current_path.__name__} MSG: '{path}' is no valid path." ERROR_MESSAGE = (
logger.error(ERROR_MESSAGE) f"FUNC: {get_current_path.__name__} MSG: '{path}' does not exist"
)
logger.warning(ERROR_MESSAGE)
print(ERROR_MESSAGE) print(ERROR_MESSAGE)
sys.exit(1) sys.exit(1)

View File

@@ -1,3 +1,4 @@
from logging import log
import os import os
from pathlib import Path from pathlib import Path
import sys import sys
@@ -20,33 +21,13 @@ class Refit_Create:
def __init__(self, args): def __init__(self, args):
"""Initiating variables for creation""" """Initiating variables for creation"""
self.args = args
self.name = args.name self.name = args.name
self.input = args.input self.input = args.input
self.n = args.n self.n = args.n
self.filemode = args.filemode self.filemode = args.filemode
self.recursive = args.recursive self.recursive = args.recursive
self.args = args
# def create_input_valid(self, args):
# """Checks if the input is argument for its existence. If no input
# argument with a value is passed, the current directory is used and
# passed to the input"""
# logger.debug(f"Start create_input_valid() value= {self.input}")
# logger.debug(f"FUNC: create_input_valid() MSG: arguments: {args}")
# if self.input is None:
# input = "."
# self.input = input
# logger.info(
# f"FUNC: create_input_valid MSG: Usingsing current directory as input. value={self.input} "
# )
# return self.input
# else:
# logger.debug(
# f"FUNC: create_input_valid() MSG: Exit with valid input. value= {self.input}"
# )
# return True
def create_n_folders(self, n, input, name): def create_n_folders(self, n, input, name):
"""Creates an set ammount of folders. Using the default directory """Creates an set ammount of folders. Using the default directory
@@ -119,39 +100,54 @@ class Refit_Create:
# Counting down n for the next ieration of the while-loop # Counting down n for the next ieration of the while-loop
n -= 1 n -= 1
def input_validator(self):
logger.debug("FUNC: input_validator()")
return True
def rf_create_decider(self): def rf_create_decider(self):
"""Coordination of the 'create' sub command""" """Coordination of the 'create' sub command"""
logger.debug("FUNC: rf_create_decider() MSG: Entered decider function") logger.debug("FUNC: rf_create_decider() MSG: Entered decider function")
# !!!ToDo: implement input_validator()
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) self.input = librefit.get_current_path(self.input)
print(self.input) logger.debug(
f"FUNC: rf_create_decider() MSG: successfully retrievd input value: '{self.input}'"
)
# if self.input is None: # Exit the program if the -n argument is not passed
# self.input = "." if self.n is None:
# logger.info( logger.error(
# f"FUNC: rf_create_decider() MSG: Usingsing current directory as input. value={self.input} " f"FUNC rf_create_decider() MSG: the number value cannot be '{self.n}'"
# ) )
print("Use the '-n' flag for the create command.")
sys.exit(1)
# Exits the program if recursive and filemode flags are set at the same time
if self.filemode:
logger.debug("DECISION filemode set, creating files instead of folders")
if self.recursive is None:
self.create_n_files(self.n, self.input, self.name)
else:
logger.error("Recursive and filemode don´t work together.")
print("Recursive and filemode don´t work together.")
# if self.filemode: if self.recursive:
# logger.debug("DECISION if filemode") print("help")
# self.create_n_files(self.n, self.input, self.name)
if self.recursive is None:
# if self.recursive is False: self.create_n_folders(self.n, self.input, self.name)
# logger.debug( else:
# f"FUNC: {self.rf_create_decider.__name__} DIR-MODE | ARGS: n={self.n} input={self.input} name={self.name}" logger.debug(
# ) f"FUNC: rf_create_decider(end) MSG: given arguments: {self.args}"
# if self.n is not None: self.create_n_folders(self.n, self.input, self.name) )
# else: print(
# ERROR_MESSAGE="Please input the number on how many objects you want to create" "Use '-n' argument to create directories.\nPlease use 'refit create -h' for help"
)
# else: sys.exit(1)
# 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): def __call__(self):
"""Gets called when the 'create' subcommand is used.""" """Gets called when the 'create' subcommand is used."""

View File

@@ -84,7 +84,7 @@ args = parser.parse_args()
# Dispatcher # Dispatcher
# determines what code gets addressed based of the users choosen flags. # determines what code gets addressed based of the users chosen flags.
if hasattr(args, "command_class"): if hasattr(args, "command_class"):
logger.debug(f"In dispatcher with args: {args}") logger.debug(f"In dispatcher with args: {args}")
Refit_Create = args.command_class Refit_Create = args.command_class