tracktolib 0.66.3__py3-none-any.whl → 0.67.0__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.
tracktolib/s3/niquests.py CHANGED
@@ -272,9 +272,12 @@ class S3Session:
272
272
  key: str,
273
273
  on_chunk: Callable[[bytes], None] | None = None,
274
274
  chunk_size: int = 1024 * 1024,
275
+ on_start: OnDownloadStartFn | None = None,
275
276
  ) -> AsyncIterator[bytes]:
276
277
  """Download a file from S3 with streaming support."""
277
- async for chunk in s3_download_file(self._s3, self.http_client, bucket, key, chunk_size=chunk_size):
278
+ async for chunk in s3_download_file(
279
+ self._s3, self.http_client, bucket, key, chunk_size=chunk_size, on_start=on_start
280
+ ):
278
281
  if on_chunk:
279
282
  on_chunk(chunk)
280
283
  yield chunk
@@ -433,10 +436,10 @@ async def s3_put_object(
433
436
 
434
437
  See: https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObject.html
435
438
  """
439
+
436
440
  obj_params: S3ObjectParams = kwargs
437
441
  presigned_params = build_s3_presigned_params(bucket, key, obj_params)
438
442
  headers = build_s3_headers(obj_params)
439
-
440
443
  url = s3.generate_presigned_url(
441
444
  ClientMethod="put_object",
442
445
  Params=presigned_params,
@@ -478,6 +481,9 @@ async def s3_get_object(
478
481
  return resp.content
479
482
 
480
483
 
484
+ type OnDownloadStartFn = Callable[[niquests.AsyncResponse], None]
485
+
486
+
481
487
  async def s3_download_file(
482
488
  s3: botocore.client.BaseClient,
483
489
  client: niquests.AsyncSession,
@@ -485,6 +491,7 @@ async def s3_download_file(
485
491
  key: str,
486
492
  *,
487
493
  chunk_size: int = 1024 * 1024,
494
+ on_start: OnDownloadStartFn | None = None,
488
495
  ) -> AsyncIterator[bytes]:
489
496
  """Download an object from S3 with streaming support."""
490
497
  url = s3.generate_presigned_url(
@@ -493,6 +500,8 @@ async def s3_download_file(
493
500
  )
494
501
  resp = await client.get(url, stream=True)
495
502
  resp.raise_for_status()
503
+ if on_start:
504
+ on_start(resp)
496
505
  async for chunk in await resp.iter_content(chunk_size):
497
506
  yield chunk
498
507
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tracktolib
3
- Version: 0.66.3
3
+ Version: 0.67.0
4
4
  Summary: Utility library for python
5
5
  Keywords: utility
6
6
  Author-email: julien.brayere@tracktor.fr
@@ -12,10 +12,10 @@ tracktolib/pg_sync.py,sha256=PDTN37kU0BxkSZetwSAtqcW2aA8Nn4gUI2mC54gSJhg,6750
12
12
  tracktolib/pg_utils.py,sha256=ArYNdf9qsdYdzGEWmev8tZpyx8_1jaGGdkfYkauM7UM,2582
13
13
  tracktolib/s3/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
14
14
  tracktolib/s3/minio.py,sha256=wMEjkSes9Fp39fD17IctALpD6zB2xwDRQEmO7Vzan3g,1387
15
- tracktolib/s3/niquests.py,sha256=HTKEDyD9W30Ru7jeNSl9gOHgpa3UHkEdQD6cBVp_l0Q,23206
15
+ tracktolib/s3/niquests.py,sha256=9j3RxM3EfIYV1wEH0OpvT_uhJ68sXN4PwxlDAH3eBEE,23453
16
16
  tracktolib/s3/s3.py,sha256=Vi3Q6DLBm44gz6fXx6uzdbGEtJly6KzdgLYHJwU6r-U,4922
17
17
  tracktolib/tests.py,sha256=gKE--epQjgMZGXc5ydbl4zjOdmwztJS42UMV0p4hXEA,399
18
18
  tracktolib/utils.py,sha256=FP87gbL27zHXaI9My2VZYEG5ZJ7eL6SiljW5MyRutOY,6553
19
- tracktolib-0.66.3.dist-info/WHEEL,sha256=XV0cjMrO7zXhVAIyyc8aFf1VjZ33Fen4IiJk5zFlC3g,80
20
- tracktolib-0.66.3.dist-info/METADATA,sha256=4ELI18eTlJ46kdn2LLwFXwXYB-d8ZvEr1qm02lY_x78,4045
21
- tracktolib-0.66.3.dist-info/RECORD,,
19
+ tracktolib-0.67.0.dist-info/WHEEL,sha256=XV0cjMrO7zXhVAIyyc8aFf1VjZ33Fen4IiJk5zFlC3g,80
20
+ tracktolib-0.67.0.dist-info/METADATA,sha256=yJodZh9-6H2mIOQcQWguUE9zsbDqOPKLyTh3A_tHUAo,4045
21
+ tracktolib-0.67.0.dist-info/RECORD,,