Repository: davanstrien/flyswot (language: python)

Issue:
make file pattern optional
- make file pattern optional 


Discussion / hints:

Fix patch:
diff --git a/src/flyswot/core.py b/src/flyswot/core.py
index 68ce6675..6a48bfb3 100644
--- a/src/flyswot/core.py
+++ b/src/flyswot/core.py
@@ -30,22 +30,16 @@ def get_image_files_from_pattern(
 ) -> Iterator[Path]:
     """yield image files from `directory` matching pattern `str` with `ext`"""
     with console.status(
-        f"Searching for files matching {pattern} in {directory}...", spinner="dots"
-    ):
+            f"Searching for files matching {pattern} in {directory}...", spinner="dots"
+        ):
         time.sleep(1)
         if pattern:
-            match_files = Path(directory).rglob(f"**/*{pattern}*{ext}")
-            for file in match_files:
-                yield file
+            yield from Path(directory).rglob(f"**/*{pattern}*{ext}")
             console.log("Search files complete...")
         if pattern and not ext:
-            match_files = Path(directory).rglob(f"*{pattern}*")
-            for file in match_files:
-                yield file
+            yield from Path(directory).rglob(f"*{pattern}*")
         if not pattern and ext:
-            match_files = Path(directory).rglob(f"*{ext}")
-            for file in match_files:
-                yield file
+            yield from Path(directory).rglob(f"*{ext}")
         if not pattern and not ext:
             match_files = Path(directory).rglob("*")
             for file in match_files:


Test patch:
diff --git a/tests/test_core.py b/tests/test_core.py
index c4b5acde..5b6e8e43 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -196,7 +196,7 @@ def test_filter_to_preferred_ext(image_files):
     assert len(tiff_files) == 2000
     jpeg_files = list(Path(image_files).glob("*.jpg"))
     assert len(jpeg_files) == 1000
-    image_files = [f for f in Path(image_files).iterdir()]
+    image_files = list(Path(image_files).iterdir())
     return_files = list(core.filter_to_preferred_ext(image_files, [".jpg"]))
     assert len(return_files) == 2000