From 6b846b694cd2d8830aa413609acdeb979d39053d Mon Sep 17 00:00:00 2001 From: Pedro Crespo <32402063+pcrespov@users.noreply.github.com> Date: Mon, 30 May 2022 11:45:27 +0200 Subject: [PATCH] patches --- osparc/api_client.py | 6 ++++-- osparc/configuration.py | 3 ++- osparc/models/_any_of.py | 4 ++-- osparc/rest.py | 2 ++ 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/osparc/api_client.py b/osparc/api_client.py index f9882325..3cfd98e5 100644 --- a/osparc/api_client.py +++ b/osparc/api_client.py @@ -288,9 +288,11 @@ def __deserialize(self, data, klass): # convert str to class if klass in self.NATIVE_TYPES_MAPPING: klass = self.NATIVE_TYPES_MAPPING[klass] + # PATCH ---------------------- elif klass.startswith("AnyOf"): from .models._any_of import deserialize_any_of return deserialize_any_of(data, self.__deserialize) + # PATCH ---------------------- else: klass = getattr(osparc.models, klass) @@ -555,14 +557,14 @@ def __deserialize_file(self, response): filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition).group(1) path = os.path.join(os.path.dirname(path), filename) - + # PATCH ----------------- try: with open(path, "w") as f: f.write(response.data) except TypeError: with open(path, "wb") as f: f.write(response.data) - + # PATCH ----------------- return path def __deserialize_primitive(self, data, klass): diff --git a/osparc/configuration.py b/osparc/configuration.py index 3bba7071..0519e456 100644 --- a/osparc/configuration.py +++ b/osparc/configuration.py @@ -96,11 +96,12 @@ class Configuration(object): ) ) """ - + # PATCH ---------- def __init__(self, host="https://api.osparc.io", api_key=None, api_key_prefix=None, username=None, password=None, signing_info=None): + # PATCH ---------- """Constructor """ self.host = host diff --git a/osparc/models/_any_of.py b/osparc/models/_any_of.py index e6cea4c1..6528cbb0 100644 --- a/osparc/models/_any_of.py +++ b/osparc/models/_any_of.py @@ -3,13 +3,13 @@ from .file import File -AnyOfFilenumberintegerstring = Union[File, float, int, str] +AnyOfFilenumberintegerbooleanstring = Union[File, float, int, bool, str] def deserialize_any_of( data: Any, deserialize_func: Callable, ): - for klass in [File, float, int, str]: + for klass in [File, float, int, bool, str]: with suppress(Exception): return deserialize_func(data, klass) raise ValueError(f"Cannot deserialize {data}") diff --git a/osparc/rest.py b/osparc/rest.py index 4e29a250..623815a5 100644 --- a/osparc/rest.py +++ b/osparc/rest.py @@ -220,11 +220,13 @@ def request(self, method, url, query_params=None, headers=None, # In the python 3, the response.data is bytes. # we need to decode it to string. if six.PY3: + # PATCH------------------------------------- try: r.data = r.data.decode('utf8') except UnicodeDecodeError: # NOTE: hdf5 files cannot be decoded pass + # PATCH------------------------------------- if not 200 <= r.status <= 299: raise ApiException(http_resp=r)