From 06726e795e3dac7eb34eb27320f0ed21c8becb7c Mon Sep 17 00:00:00 2001 From: cantor-set Date: Thu, 18 Apr 2024 09:28:30 -0400 Subject: [PATCH] Addressed PR comments --- modules/path_utils.py | 21 --------------------- modules/util.py | 2 +- tests/test_utils.py | 4 ++++ 3 files changed, 5 insertions(+), 22 deletions(-) delete mode 100644 modules/path_utils.py diff --git a/modules/path_utils.py b/modules/path_utils.py deleted file mode 100644 index 0a021520..00000000 --- a/modules/path_utils.py +++ /dev/null @@ -1,21 +0,0 @@ - -import os - -#TODO: Use refactor to use glob instead -def get_files_from_folder(folder_path, extensions=None, name_filter=None): - if not os.path.isdir(folder_path): - raise ValueError("Folder path is not a valid directory.") - - filenames = [] - - for root, _, files in os.walk(folder_path, topdown=False): - relative_path = os.path.relpath(root, folder_path) - if relative_path == ".": - relative_path = "" - for filename in sorted(files, key=lambda s: s.casefold()): - _, file_extension = os.path.splitext(filename) - if (extensions is None or file_extension.lower() in extensions) and (name_filter is None or name_filter in _): - path = os.path.join(relative_path, filename) - filenames.append(path) - - return filenames diff --git a/modules/util.py b/modules/util.py index 8b641ea0..f1b6ddf3 100644 --- a/modules/util.py +++ b/modules/util.py @@ -20,7 +20,7 @@ LANCZOS = (Image.Resampling.LANCZOS if hasattr(Image, 'Resampling') else Image.L # Regexp compiled once. Matches entries with the following pattern: # # -LORAS_PROMPT_PATTERN = re.compile(".*.*") +LORAS_PROMPT_PATTERN = re.compile(r".* .*", re.X) HASH_SHA256_LENGTH = 10 diff --git a/tests/test_utils.py b/tests/test_utils.py index c9861c9b..7b1cf87c 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -35,6 +35,10 @@ class TestUtils(unittest.TestCase): "input": ("some prompt, very cool, ", [], 3), "output": [("you-lora.safetensors", 0.2)], }, + { + "input": (", , and ",[], 6), + "output": [] + } ] for test in test_cases: