Skip to content

Commit

Permalink
Accept pathlib paths as input. Fixes #282
Browse files Browse the repository at this point in the history
  • Loading branch information
iainrussell committed Feb 11, 2022
1 parent 08eaa17 commit 3a53b3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog for cfgrib
0.9.10.1 (unreleased)
---------------------

- Nothing changed yet.
- Fix passing of pathlib.Path.
See `#282 <https://github.com/ecmwf/cfgrib/issues/282>`_.


0.9.10.0 (2022-01-31)
Expand Down
3 changes: 2 additions & 1 deletion cfgrib/xarray_plugin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import pathlib
import typing as T
from distutils.version import LooseVersion

Expand Down Expand Up @@ -32,7 +33,7 @@ def __init__(
if lock is None:
lock = ECCODES_LOCK
self.lock = xr.backends.locks.ensure_lock(lock) # type: ignore
if isinstance(filename, str):
if isinstance(filename, (str, pathlib.PurePath)):
opener = dataset.open_file
else:
opener = dataset.open_fieldset
Expand Down

0 comments on commit 3a53b3a

Please sign in to comment.