modified to use librefit

This commit is contained in:
2025-09-28 17:19:44 +02:00
parent c48e16fdb9
commit 37fe1f5203

View File

@@ -1,8 +1,7 @@
import os import os
import pathlib
import sys
from .refit_logger import logger from .refit_logger import logger
from . import librefit
logger.debug("Initiated refit_create.py") logger.debug("Initiated refit_create.py")
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
@@ -42,38 +41,27 @@ class Refit_Create:
logger.debug("in create_n_folders()") logger.debug("in create_n_folders()")
# Sets the default directory name. # Creating the length of the suffix number_string.
if name is None:
logger.debug("name argument is 'None', applying default name")
name = "directory"
else:
logger.debug(f"{name}, Type: {type(name)}, Length: {len(name)}")
# Checks if multiple names are passed to the --name argument
# if so, only the first one gets used.
if len(name) > 1:
_NAMES_WARNING = f"{len(name)} names given, only one required.\nContinuing with '{name[0]}' as name."
logger.warning(_NAMES_WARNING)
print(_NAMES_WARNING)
name = name[0]
logger.debug(f"{name}, Type: {type(name)}")
# Creating the length of the suffix.
length_n = len(str(n)) length_n = len(str(n))
# Get either the default folder name or the input name as string.
folder_name = librefit.get_standard_folder_name(name)
logger.debug(f"Length of numbering string:{length_n}") logger.debug(f"Length of numbering string:{length_n}")
logger.debug(f"Folder name: {folder_name}")
while n > 0: while n > 0:
# Creating the suffix string, filling the numbers to len of arg.n # iterating down for the files number.
i = str(n - 1) i = str(n - 1)
number_string = str.zfill(i, length_n)
# Passing the number and the length of the string to get the string back.
number_string = librefit.get_standard_name_number(i, length_n)
# Creating path for the folder # Creating path for the folder
temp_name = f"{name}_{number_string}" temp_name = f"{folder_name}_{number_string}"
rfc_path = os.path.join(input, temp_name) folder_creation_path = os.path.join(input, temp_name)
# Creating folder and subtracting n by one for the number_string # Creating folder and subtracting n by one for the number_string
os.mkdir(rfc_path) os.mkdir(folder_creation_path)
n -= 1 n -= 1
def rf_create_decider(self): def rf_create_decider(self):