Skip to content

Commit

Permalink
Remove special case in guess_engines (#4777)
Browse files Browse the repository at this point in the history
* Remove special case in guess_engines

* Sync the error messages between APIv1 and APIv2
  • Loading branch information
alexamici authored Jan 8, 2021
1 parent 1ae9778 commit 5ddb8d5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
5 changes: 0 additions & 5 deletions xarray/backends/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ def list_engines():
def guess_engine(store_spec):
engines = list_engines()

# use the pre-defined selection order for netCDF files
for engine in ["netcdf4", "h5netcdf", "scipy"]:
if engine in engines and engines[engine].guess_can_open(store_spec):
return engine

for engine, backend in engines.items():
try:
if backend.guess_can_open and backend.guess_can_open(store_spec):
Expand Down
1 change: 1 addition & 0 deletions xarray/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,7 @@ def read_magic_number(filename_or_obj, count=8):
elif isinstance(filename_or_obj, io.IOBase):
if filename_or_obj.tell() != 0:
raise ValueError(
"cannot guess the engine, "
"file-like object read/write pointer not at the start of the file, "
"please close and reopen, or use a context manager"
)
Expand Down
2 changes: 1 addition & 1 deletion xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -2661,7 +2661,7 @@ def test_open_fileobj(self):
open_dataset(f, engine="scipy")

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


Expand Down

0 comments on commit 5ddb8d5

Please sign in to comment.