From 3a53b3a74bef80557d630f5eea2ba05934f07383 Mon Sep 17 00:00:00 2001 From: Iain Russell Date: Fri, 11 Feb 2022 15:09:24 +0000 Subject: [PATCH] Accept pathlib paths as input. Fixes #282 --- CHANGELOG.rst | 3 ++- cfgrib/xarray_plugin.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1b285046..c460c2e5 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,7 +5,8 @@ Changelog for cfgrib 0.9.10.1 (unreleased) --------------------- -- Nothing changed yet. +- Fix passing of pathlib.Path. + See `#282 `_. 0.9.10.0 (2022-01-31) diff --git a/cfgrib/xarray_plugin.py b/cfgrib/xarray_plugin.py index 3b0fc83f..1b01d82f 100644 --- a/cfgrib/xarray_plugin.py +++ b/cfgrib/xarray_plugin.py @@ -1,4 +1,5 @@ import os +import pathlib import typing as T from distutils.version import LooseVersion @@ -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