decider WIP

This commit is contained in:
2025-10-01 08:06:26 +02:00
parent efcec653cb
commit caff94ab41
3 changed files with 27 additions and 21 deletions

View File

@@ -16,6 +16,7 @@
- ~~make input default the current directory and the second argument after `refit create`~~
- ~~maybe get rid of valid input ??~~
- 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()
- get rid of input argument, default to current directory and and make it positional
# Changelog

View File

@@ -1,3 +1,4 @@
from logging import log
import os
from pathlib import Path
import sys
@@ -28,25 +29,25 @@ class Refit_Create:
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"""
# 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
# 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
@@ -134,11 +135,14 @@ class Refit_Create:
if self.filemode:
logger.debug("DECISION if filemode")
self.create_n_files(self.n, self.input, self.name)
elif self.n is not None:
elif self.n is not None and self.recursive is False:
logger.debug(
f"DIR-MODE | ARGS: n={self.n} input={self.input} name={self.name}"
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(

View File

@@ -73,7 +73,8 @@ create_parser.add_argument(
create_parser.add_argument(
"-r",
"--recursive",
nargs="*",
action="store_true",
# nargs="*",
help="Sets the recursive mode for folders to true. First argumet\n is for the depth and the second for the width.",
)
create_parser.set_defaults(command_class=Refit_Create)