eodag 3.8.0__py3-none-any.whl → 3.8.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
eodag/api/core.py CHANGED
@@ -1117,7 +1117,8 @@ class EODataAccessGateway:
1117
1117
  if not (max_start <= min_end):
1118
1118
  continue
1119
1119
 
1120
- guesses_with_score.append((pt_id, score))
1120
+ pt_alias = pt_dict.get("alias", pt_id)
1121
+ guesses_with_score.append((pt_alias, score))
1121
1122
 
1122
1123
  if guesses_with_score:
1123
1124
  # sort by score descending, then pt_id for stability
@@ -523,7 +523,7 @@ def format_metadata(search_param: str, *args: Any, **kwargs: Any) -> str:
523
523
  value = MetadataFormatter.convert_to_geojson(value)
524
524
  elif not isinstance(value, str):
525
525
  raise TypeError(
526
- f"convert_replace_str expects a string or a dict (apply to_geojson). Got {type(value)}"
526
+ f"convert_replace_str expects a string or a dict (apply to_geojson). Got {type(value)}: {value}"
527
527
  )
528
528
 
529
529
  old, new = ast.literal_eval(args)
@@ -18,6 +18,7 @@
18
18
  from __future__ import annotations
19
19
 
20
20
  import logging
21
+ import re
21
22
  from json import JSONDecodeError
22
23
  from typing import TYPE_CHECKING, Optional
23
24
 
@@ -29,6 +30,8 @@ from eodag.utils import HTTP_REQ_TIMEOUT, USER_AGENT, deepcopy, format_dict_item
29
30
  from eodag.utils.exceptions import AuthenticationError, TimeOutError
30
31
 
31
32
  if TYPE_CHECKING:
33
+ from typing import Pattern
34
+
32
35
  from requests import PreparedRequest
33
36
 
34
37
 
@@ -44,15 +47,24 @@ class RequestsSASAuth(AuthBase):
44
47
  signed_url_key: str,
45
48
  headers: Optional[dict[str, str]] = None,
46
49
  ssl_verify: bool = True,
50
+ matching_url: Optional[Pattern[str]] = None,
47
51
  ) -> None:
48
52
  self.auth_uri = auth_uri
49
53
  self.signed_url_key = signed_url_key
50
54
  self.headers = headers
51
55
  self.signed_urls: dict[str, str] = {}
52
56
  self.ssl_verify = ssl_verify
57
+ self.matching_url = matching_url
53
58
 
54
59
  def __call__(self, request: PreparedRequest) -> PreparedRequest:
55
60
  """Perform the actual authentication"""
61
+ # if matching_url is set, check if request.url matches
62
+ if (
63
+ self.matching_url
64
+ and request.url
65
+ and not self.matching_url.match(request.url)
66
+ ):
67
+ return request
56
68
 
57
69
  # update headers
58
70
  if self.headers and isinstance(self.headers, dict):
@@ -118,6 +130,8 @@ class SASAuth(Authentication):
118
130
  # update headers with subscription key if exists
119
131
  apikey = getattr(self.config, "credentials", {}).get("apikey")
120
132
  ssl_verify = getattr(self.config, "ssl_verify", True)
133
+ if matching_url := getattr(self.config, "matching_url", None):
134
+ matching_url = re.compile(matching_url)
121
135
  if apikey:
122
136
  headers_update = format_dict_items(self.config.headers, apikey=apikey)
123
137
  headers.update(headers_update)
@@ -127,4 +141,5 @@ class SASAuth(Authentication):
127
141
  signed_url_key=self.config.signed_url_key,
128
142
  headers=headers,
129
143
  ssl_verify=ssl_verify,
144
+ matching_url=matching_url,
130
145
  )