From e2dfcc91ce39b0526ddd45d624963472118c3c0f Mon Sep 17 00:00:00 2001 From: Timmy Welch Date: Thu, 13 Apr 2023 20:58:30 -0600 Subject: [PATCH] Revert get_recursive_filelist Fixes #449 --- comicapi/utils.py | 9 +++++---- tests/utils_test.py | 5 ++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/comicapi/utils.py b/comicapi/utils.py index ad54ed7..797b969 100644 --- a/comicapi/utils.py +++ b/comicapi/utils.py @@ -14,7 +14,6 @@ # limitations under the License. from __future__ import annotations -import glob import json import logging import os @@ -65,9 +64,11 @@ def get_recursive_filelist(pathlist: list[str]) -> list[str]: filelist: list[str] = [] for p in pathlist: if os.path.isdir(p): - filelist.extend(x for x in glob.glob(f"{p}{os.sep}/**", recursive=True) if not os.path.isdir(x)) - elif str(p) not in filelist: - filelist.append(str(p)) + for root, _, files in os.walk(p): + for f in files: + filelist.append(os.path.join(root, f)) + else: + filelist.append(p) return filelist diff --git a/tests/utils_test.py b/tests/utils_test.py index ba525ee..b5d00d7 100644 --- a/tests/utils_test.py +++ b/tests/utils_test.py @@ -27,8 +27,11 @@ def test_recursive_list_with_file(tmp_path) -> None: temp_txt2 = tmp_path / "info2.txt" temp_txt2.write_text("this is here") + glob_in_name = tmp_path / "[e-b]" + glob_in_name.mkdir() + expected_result = {str(foo_png), str(temp_cbr), str(temp_file), str(temp_txt), str(temp_txt2)} - result = set(comicapi.utils.get_recursive_filelist([str(temp_txt2), tmp_path])) + result = set(comicapi.utils.get_recursive_filelist([str(temp_txt2), tmp_path, str(glob_in_name)])) assert result == expected_result