Skip to content

Commit 9a71990

Browse files
observingCloudsdcherianpre-commit-ci[bot]
authored
pdyap version dependent client.open_url call (#6656)
Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent d7931f9 commit 9a71990

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

doc/whats-new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Bug fixes
3434
allowing the ``encoding`` and ``unlimited_dims`` options with ``save_mfdataset``.
3535
(:issue:`6684`)
3636
By `Travis A. O'Brien <https://github.com/taobrienlbl>`_.
37+
- Fix backend support of pydap versions <3.3.0 (:issue:`6648`, :pull:`6656`).
38+
By `Hauke Schulz <https://github.com/observingClouds>`_.
3739
- :py:meth:`Dataset.where` with ``drop=True`` now behaves correctly with mixed dimensions.
3840
(:issue:`6227`, :pull:`6690`)
3941
By `Michael Niklas <https://github.com/headtr1ck>`_.

xarray/backends/pydap_.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import numpy as np
4+
from packaging.version import Version
45

56
from ..core import indexing
67
from ..core.pycompat import integer_types
@@ -17,7 +18,9 @@
1718

1819
try:
1920
import pydap.client
21+
import pydap.lib
2022

23+
pydap_version = pydap.lib.__version__
2124
has_pydap = True
2225
except ModuleNotFoundError:
2326
has_pydap = False
@@ -99,29 +102,24 @@ def open(
99102
user_charset=None,
100103
):
101104

102-
if output_grid is None:
103-
output_grid = True
104-
105-
if verify is None:
106-
verify = True
107-
108105
if timeout is None:
109106
from pydap.lib import DEFAULT_TIMEOUT
110107

111108
timeout = DEFAULT_TIMEOUT
112109

113-
if user_charset is None:
114-
user_charset = "ascii"
115-
116-
ds = pydap.client.open_url(
117-
url=url,
118-
application=application,
119-
session=session,
120-
output_grid=output_grid,
121-
timeout=timeout,
122-
verify=verify,
123-
user_charset=user_charset,
124-
)
110+
kwargs = {
111+
"url": url,
112+
"application": application,
113+
"session": session,
114+
"output_grid": output_grid or True,
115+
"timeout": timeout,
116+
}
117+
if Version(pydap_version) >= Version("3.3.0"):
118+
if verify is not None:
119+
kwargs.update({"verify": verify})
120+
if user_charset is not None:
121+
kwargs.update({"user_charset": user_charset})
122+
ds = pydap.client.open_url(**kwargs)
125123
return cls(ds)
126124

127125
def open_store_variable(self, var):

0 commit comments

Comments
 (0)