Skip to content

Commit cee567c

Browse files
authored
Adapt interfaces to camelcase (#200)
* Adapt interfaces to camelcase * Small fix
1 parent aa0e448 commit cee567c

File tree

2 files changed

+72
-12
lines changed

2 files changed

+72
-12
lines changed

firecrest/v2/_async/Client.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ async def upload_file_to_stage(self):
149149
"transferDirectives", {}
150150
).get("parts_upload_urls")
151151

152+
if urls is None:
153+
urls = self._transfer_info.get(
154+
"transferDirectives", {}
155+
).get("partsUploadUrls")
156+
152157
if urls is None:
153158
raise MultipartUploadException(
154159
self._transfer_info,
@@ -178,6 +183,11 @@ async def _upload_part(self, url, index):
178183
"transferDirectives", {}
179184
).get("max_part_size")
180185

186+
if chunk_size is None:
187+
chunk_size = self._transfer_info.get(
188+
"transferDirectives", {}
189+
).get("maxPartSize")
190+
181191
if chunk_size is None:
182192
raise MultipartUploadException(
183193
self._transfer_info,
@@ -241,6 +251,11 @@ async def _complete_upload(self, checksum):
241251
"transferDirectives", {}
242252
).get("complete_upload_url")
243253

254+
if url is None:
255+
url = self._transfer_info.get(
256+
"transferDirectives", {}
257+
).get("completeUploadUrl")
258+
244259
if url is None:
245260
raise MultipartUploadException(
246261
self._transfer_info,
@@ -309,6 +324,11 @@ async def download_file_from_stage(self, file_path=None):
309324
"transferDirectives", {}
310325
).get("download_url")
311326

327+
if download_url is None:
328+
download_url = self._transfer_info.get(
329+
"transferDirectives", {}
330+
).get("downloadUrl")
331+
312332
if download_url is None:
313333
raise MultipartUploadException(
314334
self._transfer_info,
@@ -1550,9 +1570,14 @@ async def upload(
15501570
local_file=local_file,
15511571
)
15521572

1553-
actual_transfer_method = transfer_info.get(
1554-
"transferDirectives", {}
1555-
).get("transfer_method", "s3")
1573+
trans_dir = transfer_info.get("transferDirectives", {})
1574+
if trans_dir:
1575+
actual_transfer_method = trans_dir.get(
1576+
"transferMethod",
1577+
trans_dir.get("transfer_method", "s3")
1578+
)
1579+
else:
1580+
actual_transfer_method = "s3"
15561581

15571582
if blocking:
15581583
self.log(
@@ -1677,9 +1702,14 @@ async def download(
16771702
file_path=target_path
16781703
)
16791704

1680-
actual_transfer_method = transfer_info.get(
1681-
"transferDirectives", {}
1682-
).get("transfer_method", "s3")
1705+
trans_dir = transfer_info.get("transferDirectives", {})
1706+
if trans_dir:
1707+
actual_transfer_method = trans_dir.get(
1708+
"transferMethod",
1709+
trans_dir.get("transfer_method", "s3")
1710+
)
1711+
else:
1712+
actual_transfer_method = "s3"
16831713

16841714
if blocking:
16851715
self.log(

firecrest/v2/_sync/Client.py

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ def upload_file_to_stage(self):
149149
"transferDirectives", {}
150150
).get("parts_upload_urls")
151151

152+
if urls is None:
153+
urls = self._transfer_info.get(
154+
"transferDirectives", {}
155+
).get("partsUploadUrls")
156+
152157
if urls is None:
153158
raise MultipartUploadException(
154159
self._transfer_info,
@@ -177,6 +182,11 @@ def _upload_part(self, url, index):
177182
"transferDirectives", {}
178183
).get("max_part_size")
179184

185+
if chunk_size is None:
186+
chunk_size = self._transfer_info.get(
187+
"transferDirectives", {}
188+
).get("maxPartSize")
189+
180190
if chunk_size is None:
181191
raise MultipartUploadException(
182192
self._transfer_info,
@@ -250,6 +260,11 @@ def _complete_upload(self, checksum):
250260
"transferDirectives", {}
251261
).get("complete_upload_url")
252262

263+
if url is None:
264+
url = self._transfer_info.get(
265+
"transferDirectives", {}
266+
).get("completeUploadUrl")
267+
253268
if url is None:
254269
raise MultipartUploadException(
255270
self._transfer_info,
@@ -318,6 +333,11 @@ def download_file_from_stage(self, file_path=None):
318333
"transferDirectives", {}
319334
).get("download_url")
320335

336+
if download_url is None:
337+
download_url = self._transfer_info.get(
338+
"transferDirectives", {}
339+
).get("downloadUrl")
340+
321341
if download_url is None:
322342
raise MultipartUploadException(
323343
self._transfer_info,
@@ -1560,9 +1580,14 @@ def upload(
15601580
file_size=local_file_size,
15611581
)
15621582

1563-
actual_transfer_method = transfer_info.get(
1564-
"transferDirectives", {}
1565-
).get("transfer_method", "s3")
1583+
trans_dir = transfer_info.get("transferDirectives", {})
1584+
if trans_dir:
1585+
actual_transfer_method = trans_dir.get(
1586+
"transferMethod",
1587+
trans_dir.get("transfer_method", "s3")
1588+
)
1589+
else:
1590+
actual_transfer_method = "s3"
15661591

15671592
if blocking:
15681593
self.log(
@@ -1690,9 +1715,14 @@ def download(
16901715
file_path=target_path
16911716
)
16921717

1693-
actual_transfer_method = transfer_info.get(
1694-
"transferDirectives", {}
1695-
).get("transfer_method", "s3")
1718+
trans_dir = transfer_info.get("transferDirectives", {})
1719+
if trans_dir:
1720+
actual_transfer_method = trans_dir.get(
1721+
"transferMethod",
1722+
trans_dir.get("transfer_method", "s3")
1723+
)
1724+
else:
1725+
actual_transfer_method = "s3"
16961726

16971727
if blocking:
16981728
self.log(

0 commit comments

Comments
 (0)