Skip to content

Commit 5ddb8d5

Browse files
authored
Remove special case in guess_engines (#4777)
* Remove special case in guess_engines * Sync the error messages between APIv1 and APIv2
1 parent 1ae9778 commit 5ddb8d5

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed

xarray/backends/plugins.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ def list_engines():
104104
def guess_engine(store_spec):
105105
engines = list_engines()
106106

107-
# use the pre-defined selection order for netCDF files
108-
for engine in ["netcdf4", "h5netcdf", "scipy"]:
109-
if engine in engines and engines[engine].guess_can_open(store_spec):
110-
return engine
111-
112107
for engine, backend in engines.items():
113108
try:
114109
if backend.guess_can_open and backend.guess_can_open(store_spec):

xarray/core/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ def read_magic_number(filename_or_obj, count=8):
636636
elif isinstance(filename_or_obj, io.IOBase):
637637
if filename_or_obj.tell() != 0:
638638
raise ValueError(
639+
"cannot guess the engine, "
639640
"file-like object read/write pointer not at the start of the file, "
640641
"please close and reopen, or use a context manager"
641642
)

xarray/tests/test_backends.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2661,7 +2661,7 @@ def test_open_fileobj(self):
26612661
open_dataset(f, engine="scipy")
26622662

26632663
f.seek(8)
2664-
with raises_regex(ValueError, "read/write pointer not at the start"):
2664+
with raises_regex(ValueError, "cannot guess the engine"):
26652665
open_dataset(f)
26662666

26672667

0 commit comments

Comments
 (0)