Skip to content

Commit

Permalink
pdyap version dependent client.open_url call (#6656)
Browse files Browse the repository at this point in the history
Co-authored-by: Deepak Cherian <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 16, 2022
1 parent d7931f9 commit 9a71990
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Bug fixes
allowing the ``encoding`` and ``unlimited_dims`` options with ``save_mfdataset``.
(:issue:`6684`)
By `Travis A. O'Brien <https://github.com/taobrienlbl>`_.
- Fix backend support of pydap versions <3.3.0 (:issue:`6648`, :pull:`6656`).
By `Hauke Schulz <https://github.com/observingClouds>`_.
- :py:meth:`Dataset.where` with ``drop=True`` now behaves correctly with mixed dimensions.
(:issue:`6227`, :pull:`6690`)
By `Michael Niklas <https://github.com/headtr1ck>`_.
Expand Down
34 changes: 16 additions & 18 deletions xarray/backends/pydap_.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

import numpy as np
from packaging.version import Version

from ..core import indexing
from ..core.pycompat import integer_types
Expand All @@ -17,7 +18,9 @@

try:
import pydap.client
import pydap.lib

pydap_version = pydap.lib.__version__
has_pydap = True
except ModuleNotFoundError:
has_pydap = False
Expand Down Expand Up @@ -99,29 +102,24 @@ def open(
user_charset=None,
):

if output_grid is None:
output_grid = True

if verify is None:
verify = True

if timeout is None:
from pydap.lib import DEFAULT_TIMEOUT

timeout = DEFAULT_TIMEOUT

if user_charset is None:
user_charset = "ascii"

ds = pydap.client.open_url(
url=url,
application=application,
session=session,
output_grid=output_grid,
timeout=timeout,
verify=verify,
user_charset=user_charset,
)
kwargs = {
"url": url,
"application": application,
"session": session,
"output_grid": output_grid or True,
"timeout": timeout,
}
if Version(pydap_version) >= Version("3.3.0"):
if verify is not None:
kwargs.update({"verify": verify})
if user_charset is not None:
kwargs.update({"user_charset": user_charset})
ds = pydap.client.open_url(**kwargs)
return cls(ds)

def open_store_variable(self, var):
Expand Down

0 comments on commit 9a71990

Please sign in to comment.