Revert get_recursive_filelist Fixes #449

This commit is contained in:
Timmy Welch 2023-04-13 20:58:30 -06:00
parent 33796aa475
commit e2dfcc91ce
No known key found for this signature in database
2 changed files with 9 additions and 5 deletions

View File

@ -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

View File

@ -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