Skip to content

Commit 1776519

Browse files
committed
Fix file glob not correctly reading sdfs with prefixed files
1 parent f4dd3d7 commit 1776519

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/sdf_xarray/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def _resolve_glob(path_glob: PathLike | Iterable[PathLike]):
103103

104104
try:
105105
p = Path(path_glob)
106-
paths = list(p.parent.glob(p.name)) if p.name == "*.sdf" else list(p)
106+
paths = list(p.parent.glob(p.name)) if p.name.endswith("*.sdf") else list(p)
107107
except TypeError:
108108
paths = list({Path(p) for p in path_glob})
109109

tests/test_dataset.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,18 @@ def test_resolve_glob_from_string_pattern():
212212
assert result == expected
213213

214214

215+
def test_resolve_glob_from_multiple_names_string_pattern(tmp_path):
216+
mock_test_files_dir = tmp_path
217+
(mock_test_files_dir / "normal_0000.sdf").touch()
218+
(mock_test_files_dir / "normal_0001.sdf").touch()
219+
(mock_test_files_dir / "other_0000.sdf").touch()
220+
221+
pattern = str(mock_test_files_dir / "normal_*.sdf")
222+
result = _resolve_glob(pattern)
223+
expected = sorted(mock_test_files_dir.glob("normal_*.sdf"))
224+
assert result == expected
225+
226+
215227
def test_resolve_glob_from_path_glob():
216228
pattern = TEST_FILES_DIR.glob("*.sdf")
217229
result = _resolve_glob(pattern)

0 commit comments

Comments
 (0)