modified .gitignore
This commit is contained in:
@@ -104,32 +104,38 @@ def get_standard_file_name(name) -> str:
|
||||
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.
|
||||
|
||||
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
|
||||
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_
|
||||
"""
|
||||
|
||||
logger.debug(f"FUNC: get_current_path() MSG: entered function with path = '{path}'")
|
||||
if path is None:
|
||||
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
|
||||
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....")
|
||||
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)
|
||||
ERROR_MESSAGE = (
|
||||
f"FUNC: {get_current_path.__name__} MSG: '{path}' does not exist"
|
||||
)
|
||||
logger.warning(ERROR_MESSAGE)
|
||||
print(ERROR_MESSAGE)
|
||||
sys.exit(1)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from logging import log
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sys
|
||||
@@ -20,33 +21,13 @@ class Refit_Create:
|
||||
|
||||
def __init__(self, args):
|
||||
"""Initiating variables for creation"""
|
||||
self.args = args
|
||||
|
||||
self.name = args.name
|
||||
self.input = args.input
|
||||
self.n = args.n
|
||||
self.filemode = args.filemode
|
||||
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):
|
||||
"""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
|
||||
n -= 1
|
||||
|
||||
def input_validator(self):
|
||||
logger.debug("FUNC: input_validator()")
|
||||
return True
|
||||
|
||||
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")
|
||||
|
||||
# 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)
|
||||
print(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} "
|
||||
# )
|
||||
logger.debug(
|
||||
f"FUNC: rf_create_decider() MSG: successfully retrievd input value: '{self.input}'"
|
||||
)
|
||||
|
||||
# Exit the program if the -n argument is not passed
|
||||
if self.n is None:
|
||||
logger.error(
|
||||
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)
|
||||
|
||||
# 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)
|
||||
# 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.recursive:
|
||||
print("help")
|
||||
|
||||
if self.recursive is None:
|
||||
self.create_n_folders(self.n, self.input, self.name)
|
||||
else:
|
||||
logger.debug(
|
||||
f"FUNC: rf_create_decider(end) 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