Skip to content

Commit

Permalink
backup
Browse files Browse the repository at this point in the history
  • Loading branch information
konstntokas committed Jun 21, 2024
1 parent 5a15163 commit a40d972
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions xcube_stac/href_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _decode_href(href: str) -> Tuple[str, str, str, dict]:
if root is None:
protocol, remain = href.split("://")
root = remain.split("/")[0]
fs_path = remain.replace(root + "/", "")
fs_path = remain.replace(f"{root}/", "")
storage_options = {}

return protocol, root, fs_path, storage_options
Expand Down Expand Up @@ -163,12 +163,12 @@ def _decode_aws_s3_href(href: str):
elif re.search(r"^https://.{3,63}\.s3-.{9,14}\.amazonaws\.com/", href) is not None:
tmp = href[8:].split("/")
region_name = tmp[0].split(".s3-")[-1][:-14]
root = tmp[0].replace(".s3-" + region_name + ".amazonaws.com", "")
root = tmp[0].replace(f".s3-{region_name}.amazonaws.com", "")
fs_path = "/".join(tmp[1:])
elif re.search(r"^https://.{3,63}\.s3\..{9,14}\.amazonaws\.com/", href) is not None:
tmp = href[8:].split("/")
region_name = tmp[0].split(".s3.")[-1][:-14]
root = tmp[0].replace(".s3." + region_name + ".amazonaws.com", "")
root = tmp[0].replace(f".s3.{region_name}.amazonaws.com", "")
fs_path = "/".join(tmp[1:])

if root is not None:
Expand Down
2 changes: 1 addition & 1 deletion xcube_stac/opener.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def open_data(
stac_schema = self.get_open_data_params_schema()
stac_schema.validate_instance(open_params)
tile_size = open_params.get("tile_size", (512, 512))
fs_path = "https://" + self._root + "/" + data_id + "#mode=bytes"
fs_path = f"https://{self._root}/{data_id}#mode=bytes"
return xr.open_dataset(fs_path, chunks={})


Expand Down
6 changes: 3 additions & 3 deletions xcube_stac/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,11 @@ def _access_item(self, data_id: str) -> Union[pystac.Item, str]:
Raises:
DataStoreError: Error, if the item json cannot be accessed.
"""
response = requests.request(method="GET", url=self._url_mod + data_id)
response = requests.request(method="GET", url=f"{self._url_mod}{data_id}")
if response.status_code == 200:
return pystac.Item.from_dict(
json.loads(response.text),
href=self._url + data_id,
href=f"{self._url_mod}{data_id}",
root=self._catalog,
preserve_dict=False,
)
Expand Down Expand Up @@ -381,7 +381,7 @@ def _build_dataset(
if len(ds_asset) == 1:
key = asset.extra_fields["id"]
else:
key = asset.extra_fields["id"] + "_" + varname
key = f"{asset.extra_fields['id']}_varname"
ds[key] = da
return ds

Expand Down

0 comments on commit a40d972

Please sign in to comment.