lsrestclient 3.0.0__tar.gz → 3.0.2__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lsrestclient
3
- Version: 3.0.0
3
+ Version: 3.0.2
4
4
  Summary: REST Api Client
5
5
  Author: mba
6
6
  Author-email: bartel@electronic-shop.lu
@@ -54,20 +54,20 @@ def raise_errors(r, exceptions: Optional[List[Type[Exception]]] = None):
54
54
  else:
55
55
  try:
56
56
  json = r.json()
57
- detail = pydash.get(json, "detail", json)
58
- error_class = pydash.get(detail, "error_class", None)
59
- if error_class is not None:
60
- payload = pydash.get(detail, "error_payload", {})
61
- else:
62
- error_class = pydash.get(detail, "ERROR_CLASS", None)
63
- payload = {}
64
-
65
- if error_class in exceptions_by_class:
66
- e = exceptions_by_class[error_class](**payload)
67
- raise e
68
- # backend errors
69
- raise WebException(status_code=r.status_code, detail=detail)
70
-
71
57
  except Exception as e:
72
58
  log.error(r.content)
73
59
  raise WebException(status_code=r.status_code, detail=r.content)
60
+
61
+ detail = pydash.get(json, "detail", json)
62
+ error_class = pydash.get(detail, "error_class", None)
63
+ if error_class is not None:
64
+ payload = pydash.get(detail, "error_payload", {})
65
+ else:
66
+ error_class = pydash.get(detail, "ERROR_CLASS", None)
67
+ payload = {}
68
+
69
+ if error_class in exceptions_by_class:
70
+ e = exceptions_by_class[error_class](**payload)
71
+ raise e
72
+ # backend errors
73
+ raise WebException(status_code=r.status_code, detail=detail)
@@ -6,6 +6,7 @@ import pydash
6
6
  from requests import Response
7
7
  from requests.structures import CaseInsensitiveDict
8
8
 
9
+
9
10
  @dataclass
10
11
  class LsRestClientResponse:
11
12
  """
@@ -19,7 +20,7 @@ class LsRestClientResponse:
19
20
  _json: Optional[dict] = None
20
21
 
21
22
  def json(self):
22
- if self._json is None:
23
+ if self._json is None and self.content != "":
23
24
  self._json = lsjsonclasses.LSoftJSONDecoder.loads(self.content)
24
25
  return self._json
25
26
 
@@ -37,7 +38,7 @@ class LsRestClientResponse:
37
38
  encoding = pydash.get(response, "encoding", None)
38
39
  headers = pydash.get(response, "headers", None)
39
40
  content_type = headers.get("Content-Type", None)
40
- if content_type == 'application/pdf':
41
+ if content_type == "application/pdf":
41
42
  content = response.content
42
43
  else:
43
44
  content = response.content.decode("utf8" if encoding is None else encoding)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "lsrestclient"
3
- version = "3.0.0"
3
+ version = "3.0.2"
4
4
  description = "REST Api Client"
5
5
  authors = ["mba <bartel@electronic-shop.lu>"]
6
6
  readme = "README.md"
File without changes