miniopy-async 1.23.0__tar.gz → 1.23.2__tar.gz

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.
Files changed (31) hide show
  1. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/PKG-INFO +1 -2
  2. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/__init__.py +2 -8
  3. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/api.py +36 -44
  4. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/commonconfig.py +2 -8
  5. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/credentials/__init__.py +1 -7
  6. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/credentials/credentials.py +1 -3
  7. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/credentials/providers.py +7 -14
  8. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/datatypes.py +2 -8
  9. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/deleteobjects.py +2 -4
  10. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/error.py +8 -7
  11. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/helpers.py +169 -40
  12. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/legalhold.py +2 -4
  13. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/lifecycleconfig.py +2 -4
  14. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/minioadmin.py +1 -3
  15. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/notificationconfig.py +2 -4
  16. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/objectlockconfig.py +2 -4
  17. miniopy_async-1.23.2/miniopy_async/py.typed +0 -0
  18. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/replicationconfig.py +2 -4
  19. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/retention.py +2 -4
  20. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/select.py +2 -8
  21. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/signer.py +1 -7
  22. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/sse.py +1 -7
  23. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/sseconfig.py +2 -4
  24. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/tagging.py +2 -4
  25. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/time.py +2 -4
  26. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/versioningconfig.py +2 -4
  27. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/xml.py +2 -4
  28. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/pyproject.toml +2 -2
  29. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/LICENSE +0 -0
  30. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/README.md +0 -0
  31. {miniopy_async-1.23.0 → miniopy_async-1.23.2}/miniopy_async/crypto.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: miniopy-async
3
- Version: 1.23.0
3
+ Version: 1.23.2
4
4
  Summary: Asynchronous MinIO Client SDK for Python
5
5
  Home-page: https://github.com/hlf20010508/miniopy-async
6
6
  License: Apache-2.0
@@ -18,7 +18,6 @@ Classifier: Programming Language :: Python :: 3.11
18
18
  Classifier: Programming Language :: Python :: 3.12
19
19
  Classifier: Programming Language :: Python :: 3.13
20
20
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
- Requires-Dist: aiofile (>=3.9.0,<4.0.0)
22
21
  Requires-Dist: aiohttp (>=3.11.14,<4.0.0)
23
22
  Requires-Dist: aiohttp-retry (>=2.9.1,<3.0.0)
24
23
  Requires-Dist: argon2-cffi (>=23.1.0,<24.0.0)
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage,
3
3
  # (C) 2015, 2016, 2017 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -16,10 +14,6 @@
16
14
  # See the License for the specific language governing permissions and
17
15
  # limitations under the License.
18
16
 
19
- # NOTICE: This file has been changed and differs from the original
20
- # Author: L-ING
21
- # Date: 2022-07-11
22
-
23
17
  # type: ignore[reportUnusedImport]
24
18
 
25
19
  """
@@ -42,7 +36,7 @@ miniopy-async - Asynchronous MinIO Client SDK for Python
42
36
 
43
37
  __title__ = "miniopy-async"
44
38
  __author__ = "L-ING"
45
- __version__ = "1.23.0"
39
+ __version__ = "1.23.2"
46
40
  __license__ = "Apache 2.0"
47
41
  __copyright__ = "(C) 2022 L-ING <hlf01@icloud.com>"
48
42
 
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2015, 2016, 2017 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2015, 2016, 2017 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -16,10 +14,6 @@
16
14
  # See the License for the specific language governing permissions and
17
15
  # limitations under the License.
18
16
 
19
- # NOTICE: This file has been changed and differs from the original
20
- # Author: L-ING
21
- # Date: 2022-07-11
22
-
23
17
  # pylint: disable=too-many-lines,disable=too-many-branches,too-many-statements
24
18
  # pylint: disable=too-many-arguments
25
19
 
@@ -42,7 +36,6 @@ from urllib.parse import urlunsplit
42
36
  from xml.etree import ElementTree as ET
43
37
 
44
38
  import certifi
45
- from aiofile import FileIOWrapperBase, async_open
46
39
  from aiohttp import ClientResponse, ClientSession, ClientTimeout, TCPConnector
47
40
  from aiohttp.typedefs import LooseHeaders
48
41
  from aiohttp_retry import ExponentialRetry, RetryClient
@@ -79,6 +72,7 @@ from .helpers import (
79
72
  DictType,
80
73
  ObjectWriteResult,
81
74
  ProgressType,
75
+ Substream,
82
76
  check_bucket_name,
83
77
  check_object_name,
84
78
  check_sse,
@@ -90,7 +84,6 @@ from .helpers import (
90
84
  makedirs,
91
85
  md5sum_hash,
92
86
  queryencode,
93
- read_part_data,
94
87
  sha256_hash,
95
88
  )
96
89
  from .legalhold import LegalHold
@@ -272,7 +265,7 @@ class Minio: # pylint: disable=too-many-public-methods
272
265
  self,
273
266
  host: str,
274
267
  headers: LooseHeaders | DictType | None,
275
- body: bytes | BytesIO | None,
268
+ body: bytes | BytesIO | Substream | None,
276
269
  creds: Credentials | None,
277
270
  ) -> tuple[dict[str, str], datetime]:
278
271
  """Build headers with given parameters."""
@@ -283,11 +276,13 @@ class Minio: # pylint: disable=too-many-public-methods
283
276
  sha256 = None
284
277
  md5sum = None
285
278
 
286
- if isinstance(body, BytesIO):
287
- body = body.getvalue()
288
-
289
279
  if body:
290
- headers["Content-Length"] = str(len(body))
280
+ if isinstance(body, BytesIO):
281
+ headers["Content-Length"] = str(body.getbuffer().nbytes)
282
+ elif isinstance(body, Substream):
283
+ headers["Content-Length"] = str(body.size)
284
+ else:
285
+ headers["Content-Length"] = str(len(body))
291
286
  if creds:
292
287
  if self._base_url.is_https:
293
288
  sha256 = "UNSIGNED-PAYLOAD"
@@ -312,7 +307,7 @@ class Minio: # pylint: disable=too-many-public-methods
312
307
  region: str,
313
308
  bucket_name: str | None = None,
314
309
  object_name: str | None = None,
315
- body: bytes | BytesIO | None = None,
310
+ body: bytes | BytesIO | Substream | None = None,
316
311
  headers: LooseHeaders | DictType | None = None,
317
312
  query_params: DictType | None = None,
318
313
  no_body_trace: bool = False,
@@ -503,7 +498,7 @@ class Minio: # pylint: disable=too-many-public-methods
503
498
  method: str,
504
499
  bucket_name: str | None = None,
505
500
  object_name: str | None = None,
506
- body: bytes | BytesIO | None = None,
501
+ body: bytes | BytesIO | Substream | None = None,
507
502
  headers: DictType | None = None,
508
503
  query_params: DictType | None = None,
509
504
  no_body_trace: bool = False,
@@ -1489,7 +1484,7 @@ class Minio: # pylint: disable=too-many-public-methods
1489
1484
  """
1490
1485
 
1491
1486
  file_size = os.stat(file_path).st_size
1492
- async with async_open(file_path, "rb") as file_data:
1487
+ with open(file_path, "rb") as file_data:
1493
1488
  return await self.put_object(
1494
1489
  bucket_name,
1495
1490
  object_name,
@@ -1609,9 +1604,9 @@ class Minio: # pylint: disable=too-many-public-methods
1609
1604
  object_name=object_name, total_length=length
1610
1605
  )
1611
1606
 
1612
- async with async_open(tmp_file_path, "wb") as tmp_file:
1607
+ with open(tmp_file_path, "wb") as tmp_file:
1613
1608
  async for data in response.content.iter_chunked(n=1024 * 1024):
1614
- size = await tmp_file.write(data)
1609
+ size = tmp_file.write(data)
1615
1610
  if progress:
1616
1611
  await progress.update(size)
1617
1612
 
@@ -2305,7 +2300,7 @@ class Minio: # pylint: disable=too-many-public-methods
2305
2300
  self,
2306
2301
  bucket_name: str,
2307
2302
  object_name: str,
2308
- data: bytes,
2303
+ data: Substream,
2309
2304
  headers: DictType | None,
2310
2305
  query_params: DictType | None = None,
2311
2306
  ) -> ObjectWriteResult:
@@ -2314,7 +2309,7 @@ class Minio: # pylint: disable=too-many-public-methods
2314
2309
  "PUT",
2315
2310
  bucket_name,
2316
2311
  object_name,
2317
- body=BytesIO(data),
2312
+ body=data,
2318
2313
  headers=headers,
2319
2314
  query_params=query_params,
2320
2315
  no_body_trace=True,
@@ -2331,7 +2326,7 @@ class Minio: # pylint: disable=too-many-public-methods
2331
2326
  self,
2332
2327
  bucket_name: str,
2333
2328
  object_name: str,
2334
- data: bytes,
2329
+ data: Substream,
2335
2330
  headers: DictType | None,
2336
2331
  upload_id: str,
2337
2332
  part_number: int,
@@ -2365,7 +2360,7 @@ class Minio: # pylint: disable=too-many-public-methods
2365
2360
  self,
2366
2361
  bucket_name: str,
2367
2362
  object_name: str,
2368
- data: BinaryIO | FileIOWrapperBase,
2363
+ data: BinaryIO,
2369
2364
  length: int,
2370
2365
  content_type: str = "application/octet-stream",
2371
2366
  metadata: DictType | None = None,
@@ -2509,7 +2504,6 @@ class Minio: # pylint: disable=too-many-public-methods
2509
2504
  object_size = length
2510
2505
  uploaded_size = 0
2511
2506
  part_number = 0
2512
- one_byte = b""
2513
2507
  stop = False
2514
2508
  upload_id = None
2515
2509
  parts = []
@@ -2523,31 +2517,26 @@ class Minio: # pylint: disable=too-many-public-methods
2523
2517
  if part_number == part_count:
2524
2518
  part_size = object_size - uploaded_size
2525
2519
  stop = True
2526
- part_data = await read_part_data(
2527
- data,
2528
- part_size,
2529
- progress=progress,
2530
- )
2531
- if len(part_data) != part_size:
2520
+ part_data = Substream(data, uploaded_size, part_size)
2521
+ if part_data.size != part_size:
2532
2522
  raise IOError(
2533
2523
  f"stream having not enough data;"
2534
2524
  f"expected: {part_size}, "
2535
- f"got: {len(part_data)} bytes"
2525
+ f"got: {part_data.size} bytes"
2536
2526
  )
2537
2527
  else:
2538
- part_data = await read_part_data(
2539
- data, part_size + 1, one_byte, progress=progress
2540
- )
2541
- # If part_data_size is less or equal to part_size,
2542
- # then we have reached last part.
2543
- if len(part_data) <= part_size:
2528
+ part_data = Substream(data, uploaded_size, part_size)
2529
+ if part_data.size == 0:
2530
+ break
2531
+ if part_data.size < part_size:
2544
2532
  part_count = part_number
2545
2533
  stop = True
2546
- else:
2547
- one_byte = part_data[-1:]
2548
- part_data = part_data[:-1]
2534
+ part_size = part_data.size
2535
+
2536
+ if progress:
2537
+ await progress.update(part_size)
2549
2538
 
2550
- uploaded_size += len(part_data)
2539
+ uploaded_size += part_size
2551
2540
 
2552
2541
  if part_count == 1:
2553
2542
  return await self._put_object(
@@ -4166,6 +4155,7 @@ class Minio: # pylint: disable=too-many-public-methods
4166
4155
  self,
4167
4156
  bucket_name: str,
4168
4157
  object_list: Iterable[SnowballObject],
4158
+ object_name: str | None = None,
4169
4159
  metadata: DictType | None = None,
4170
4160
  sse: Sse | None = None,
4171
4161
  tags: Tags | None = None,
@@ -4182,6 +4172,8 @@ class Minio: # pylint: disable=too-many-public-methods
4182
4172
  :param str bucket_name: Name of the bucket.
4183
4173
  :param Iterable[SnowballObject] object_list: An iterable containing
4184
4174
  :class:`SnowballObject` object.
4175
+ :param str object_name: Optional name for the uploaded TAR archive.
4176
+ If not provided, a random name in the format `snowball.<random>.tar` will be used.
4185
4177
  :param DictType | None metadata: Any additional metadata to be uploaded along
4186
4178
  with your PUT request.
4187
4179
  :param Sse | None sse: Server-side encryption.
@@ -4227,7 +4219,7 @@ class Minio: # pylint: disable=too-many-public-methods
4227
4219
  """
4228
4220
  check_bucket_name(bucket_name, s3_check=self._base_url.is_aws_host)
4229
4221
 
4230
- object_name = f"snowball.{random()}.tar"
4222
+ object_name = object_name or f"snowball.{random()}.tar"
4231
4223
 
4232
4224
  # turn list like objects into an iterator.
4233
4225
  object_list = itertools.chain(object_list)
@@ -4256,7 +4248,7 @@ class Minio: # pylint: disable=too-many-public-methods
4256
4248
  else:
4257
4249
  length = os.stat(name).st_size
4258
4250
 
4259
- part_size = 0
4251
+ part_size = 0 if length < MIN_PART_SIZE else length
4260
4252
 
4261
4253
  if name:
4262
4254
  return await self.fput_object(
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -16,10 +14,6 @@
16
14
  # See the License for the specific language governing permissions and
17
15
  # limitations under the License.
18
16
 
19
- # NOTICE: This file has been changed and differs from the original
20
- # Author: L-ING
21
- # Date: 2022-07-11
22
-
23
17
  """Common request/response configuration of S3 APIs."""
24
18
  # pylint: disable=invalid-name
25
19
 
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage,
3
3
  # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -16,10 +14,6 @@
16
14
  # See the License for the specific language governing permissions and
17
15
  # limitations under the License.
18
16
 
19
- # NOTICE: This file has been changed and differs from the original
20
- # Author: L-ING
21
- # Date: 2022-07-11
22
-
23
17
  # type: ignore[reportUnusedImport]
24
18
 
25
19
  """Credential module."""
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage,
3
3
  # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage,
3
3
  # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -16,10 +14,6 @@
16
14
  # See the License for the specific language governing permissions and
17
15
  # limitations under the License.
18
16
 
19
- # NOTICE: This file has been changed and differs from the original
20
- # Author: L-ING
21
- # Date: 2022-07-11
22
-
23
17
  """Credential providers."""
24
18
 
25
19
  from __future__ import annotations
@@ -40,7 +34,6 @@ from urllib.parse import urlencode, urlsplit, urlunsplit
40
34
  from xml.etree import ElementTree as ET
41
35
 
42
36
  import certifi
43
- from aiofile import async_open
44
37
  from aiohttp import ClientResponse, ClientSession, TCPConnector
45
38
  from aiohttp.typedefs import LooseHeaders
46
39
  from aiohttp_retry import ExponentialRetry, RetryClient
@@ -339,8 +332,8 @@ class MinioClientConfigProvider(Provider):
339
332
  async def retrieve(self) -> Credentials:
340
333
  """Retrieve credential value from MinIO client configuration file."""
341
334
  try:
342
- async with async_open(self._filename, encoding="utf-8") as conf_file:
343
- config = json.loads(await conf_file.read())
335
+ with open(self._filename, encoding="utf-8") as conf_file:
336
+ config = json.loads(conf_file.read())
344
337
  aliases = config.get("hosts") or config.get("aliases")
345
338
  if not aliases:
346
339
  raise ValueError(
@@ -374,8 +367,8 @@ def _check_loopback_host(url: str):
374
367
  async def _get_jwt_token(token_file: str) -> dict[str, str]:
375
368
  """Read and return content of token file."""
376
369
  try:
377
- async with async_open(token_file, encoding="utf-8") as file:
378
- return {"access_token": await file.read(), "expires_in": "0"}
370
+ with open(token_file, encoding="utf-8") as file:
371
+ return {"access_token": file.read(), "expires_in": "0"}
379
372
  except (IOError, OSError) as exc:
380
373
  raise ValueError(f"error in reading file {token_file}") from exc
381
374
 
@@ -481,8 +474,8 @@ class IamAwsProvider(Provider):
481
474
  token = self._token
482
475
  if self._token_file:
483
476
  url = self._full_uri
484
- async with async_open(self._token_file, encoding="utf-8") as file:
485
- token = await file.read()
477
+ with open(self._token_file, encoding="utf-8") as file:
478
+ token = file.read()
486
479
  else:
487
480
  if not url:
488
481
  url = self._full_uri
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -16,10 +14,6 @@
16
14
  # See the License for the specific language governing permissions and
17
15
  # limitations under the License.
18
16
 
19
- # NOTICE: This file has been changed and differs from the original
20
- # Author: L-ING
21
- # Date: 2022-07-11
22
-
23
17
  """
24
18
  Response of ListBuckets, ListObjects, ListObjectsV2 and ListObjectVersions API.
25
19
  """
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
3
  # (C) 2015-2019 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -16,10 +14,6 @@
16
14
  # See the License for the specific language governing permissions and
17
15
  # limitations under the License.
18
16
 
19
- # NOTICE: This file has been changed and differs from the original
20
- # Author: L-ING
21
- # Date: 2022-07-11
22
-
23
17
  # pylint: disable=too-many-lines
24
18
 
25
19
  """This module provides custom exception classes for MinIO library and API specific errors."""
@@ -176,3 +170,10 @@ class MinioAdminException(Exception):
176
170
 
177
171
  def __reduce__(self):
178
172
  return type(self), (self._code, self._body)
173
+
174
+
175
+ class UnreachableError(MinioException):
176
+ """Raised when unreachable code reached."""
177
+
178
+ def __init__(self):
179
+ super().__init__("unreachable code reached, please report this issue.")
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2015, 2016, 2017 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2015, 2016, 2017 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -16,18 +14,14 @@
16
14
  # See the License for the specific language governing permissions and
17
15
  # limitations under the License.
18
16
 
19
- # NOTICE: This file has been changed and differs from the original
20
- # Author: L-ING
21
- # Date: 2022-07-11
22
-
23
17
  """Helper functions."""
24
18
 
25
19
  from __future__ import absolute_import, annotations, division, unicode_literals
26
20
 
27
- import asyncio
28
21
  import base64
29
22
  import errno
30
23
  import hashlib
24
+ import io
31
25
  import math
32
26
  import os
33
27
  import platform
@@ -36,9 +30,10 @@ import urllib.parse
36
30
  from datetime import datetime
37
31
  from typing import BinaryIO, Dict, List, Protocol, Tuple, Union
38
32
 
39
- from aiofile import FileIOWrapperBase
40
33
  from aiohttp.typedefs import LooseHeaders
41
34
 
35
+ from miniopy_async.error import UnreachableError
36
+
42
37
  from . import __title__, __version__
43
38
  from .sse import Sse, SseCustomerKey
44
39
  from .time import to_iso8601utc
@@ -214,29 +209,6 @@ class ProgressType(Protocol):
214
209
  """Set current progress length."""
215
210
 
216
211
 
217
- async def read_part_data(
218
- stream: BinaryIO | FileIOWrapperBase,
219
- size: int,
220
- part_data: bytes = b"",
221
- progress: ProgressType | None = None,
222
- ) -> bytes:
223
- """Read part data of given size from stream."""
224
- size -= len(part_data)
225
- while size:
226
- data = stream.read(size)
227
- if asyncio.iscoroutine(data):
228
- data = await data
229
- if not data:
230
- break # EOF reached
231
- if not isinstance(data, bytes):
232
- raise ValueError("read() must return 'bytes' object")
233
- part_data += data
234
- size -= len(data)
235
- if progress:
236
- await progress.update(len(data))
237
- return part_data
238
-
239
-
240
212
  def makedirs(path: str):
241
213
  """Wrapper of os.makedirs() ignores errno.EEXIST."""
242
214
  try:
@@ -335,7 +307,7 @@ def check_sse(sse: Sse | None):
335
307
  raise ValueError("Sse type is required")
336
308
 
337
309
 
338
- def md5sum_hash(data: str | bytes | None) -> str | None:
310
+ def md5sum_hash(data: str | bytes | BinaryIO | Substream | None) -> str | None:
339
311
  """Compute MD5 of data and return hash as Base64 encoded value."""
340
312
  if data is None:
341
313
  return None
@@ -346,19 +318,53 @@ def md5sum_hash(data: str | bytes | None) -> str | None:
346
318
  "md5",
347
319
  usedforsecurity=False,
348
320
  )
349
- hasher.update(data.encode() if isinstance(data, str) else data)
321
+ if isinstance(data, (str, bytes)):
322
+ hasher.update(data.encode() if isinstance(data, str) else data)
323
+ elif isinstance(data, (io.BytesIO, Substream)) and data.readable():
324
+ pos = data.tell()
325
+ data.seek(0)
326
+
327
+ chunk_size = 8192
328
+ while True:
329
+ chunk = data.read(chunk_size)
330
+ if not chunk:
331
+ break
332
+ hasher.update(chunk)
333
+
334
+ data.seek(pos)
335
+ else:
336
+ raise TypeError(
337
+ "data must be str, bytes, or BinaryIO type",
338
+ )
339
+
350
340
  md5sum = base64.b64encode(hasher.digest())
351
- return md5sum.decode() if isinstance(md5sum, bytes) else md5sum
341
+ return md5sum.decode()
352
342
 
353
343
 
354
- def sha256_hash(data: str | bytes | None) -> str:
344
+ def sha256_hash(data: str | bytes | BinaryIO | Substream | None) -> str:
355
345
  """Compute SHA-256 of data and return hash as hex encoded value."""
356
346
  data = data or b""
357
347
  hasher = hashlib.sha256()
358
- hasher.update(data.encode() if isinstance(data, str) else data)
348
+ if isinstance(data, (str, bytes)):
349
+ hasher.update(data.encode() if isinstance(data, str) else data)
350
+ elif isinstance(data, (io.BytesIO, Substream)) and data.readable():
351
+ pos = data.tell()
352
+ data.seek(0)
353
+
354
+ chunk_size = 8192
355
+ while True:
356
+ chunk = data.read(chunk_size)
357
+ if not chunk:
358
+ break
359
+ hasher.update(chunk)
360
+
361
+ data.seek(pos)
362
+ else:
363
+ raise TypeError(
364
+ "data must be str, bytes, or BinaryIO type",
365
+ )
366
+
359
367
  sha256sum = hasher.hexdigest()
360
- if isinstance(sha256sum, bytes):
361
- return sha256sum.decode()
362
368
  return sha256sum
363
369
 
364
370
 
@@ -850,3 +856,126 @@ class ObjectWriteResult:
850
856
  def location(self) -> str | None:
851
857
  """Get location."""
852
858
  return self._location
859
+
860
+
861
+ class Substream(io.IOBase):
862
+ def __init__(self, base: BinaryIO, offset: int, part_size: int):
863
+ if not (hasattr(base, "read") and hasattr(base, "seek")):
864
+ raise TypeError("Base object must support read() and seek()")
865
+
866
+ self._base = base
867
+ self._start = offset
868
+ self._size = self._get_size(part_size)
869
+ self._pos = 0
870
+ self._closed = False
871
+
872
+ def _get_size(self, part_size: int) -> int:
873
+ """Get size of the substream using bisection."""
874
+ head = self._start
875
+ tail = self._start + part_size - 1
876
+
877
+ self._base.seek(tail)
878
+ data = self._base.read(1)
879
+ if data:
880
+ return part_size
881
+
882
+ self._base.seek(head)
883
+ data = self._base.read(1)
884
+ if not data:
885
+ return 0
886
+
887
+ # bisection
888
+ while tail >= head:
889
+ center = (head + tail) // 2
890
+ self._base.seek(center)
891
+ data = self._base.read(2)
892
+ if not data:
893
+ tail = center - 1
894
+ elif len(data) == 2:
895
+ head = center + 1
896
+ else:
897
+ return center - self._start + 1
898
+
899
+ raise UnreachableError
900
+
901
+ @property
902
+ def size(self) -> int:
903
+ """Get size of the substream."""
904
+ return self._size
905
+
906
+ def read(self, size: int = -1) -> bytes:
907
+ """Read data from the substream."""
908
+ self._check_closed()
909
+ self._base.seek(self._start + self._pos)
910
+
911
+ remaining = self._size - self._pos
912
+ if remaining <= 0:
913
+ return b""
914
+ if size < 0 or size > remaining:
915
+ size = remaining
916
+ data = self._base.read(size)
917
+ self._pos += len(data)
918
+ return data
919
+
920
+ def is_empty(self) -> bool:
921
+ """Check if the substream is empty."""
922
+ pos = self._pos
923
+
924
+ self.seek(0)
925
+ if not self.read(1):
926
+ return True
927
+
928
+ self._pos = pos
929
+ return False
930
+
931
+ def seek(self, offset: int, whence: int = io.SEEK_SET) -> int:
932
+ """Seek to a position in the substream."""
933
+ if whence == io.SEEK_SET:
934
+ new_pos = offset
935
+ elif whence == io.SEEK_CUR:
936
+ new_pos = self._pos + offset
937
+ elif whence == io.SEEK_END:
938
+ new_pos = self._size + offset
939
+ else:
940
+ raise ValueError(f"Invalid whence: {whence!r}")
941
+
942
+ if not 0 <= new_pos <= self._size:
943
+ raise ValueError("seek position out of range")
944
+
945
+ self._pos = new_pos
946
+ return self._pos
947
+
948
+ def tell(self) -> int:
949
+ """Return the current position in the substream."""
950
+ self._check_closed()
951
+ return self._pos
952
+
953
+ def readable(self) -> bool:
954
+ """Check if the substream is readable."""
955
+ return True
956
+
957
+ def seekable(self) -> bool:
958
+ """Check if the substream is seekable."""
959
+ return True
960
+
961
+ def close(self) -> None:
962
+ self._closed = True
963
+
964
+ @property
965
+ def closed(self) -> bool:
966
+ return self._closed
967
+
968
+ def _check_closed(self) -> None:
969
+ if self._closed:
970
+ raise ValueError("I/O operation on closed file.")
971
+
972
+ def __enter__(self):
973
+ self._check_closed()
974
+ return self
975
+
976
+ def __exit__(self, exc_type, exc_val, exc_tb):
977
+ self.close()
978
+
979
+ def remaining(self) -> int:
980
+ """Bytes left to read."""
981
+ return max(0, self._size - self._pos)
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2015, 2016, 2017, 2018, 2019 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2015, 2016, 2017, 2018, 2019 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
3
  # (C) 2021 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2021 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
File without changes
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -16,10 +14,6 @@
16
14
  # See the License for the specific language governing permissions and
17
15
  # limitations under the License.
18
16
 
19
- # NOTICE: This file has been changed and differs from the original
20
- # Author: L-ING
21
- # Date: 2022-07-11
22
-
23
17
  """Request/response of SelectObjectContent API."""
24
18
 
25
19
  from __future__ import absolute_import, annotations
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
3
  # (C) 2015-2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -16,10 +14,6 @@
16
14
  # See the License for the specific language governing permissions and
17
15
  # limitations under the License.
18
16
 
19
- # NOTICE: This file has been changed and differs from the original
20
- # Author: L-ING
21
- # Date: 2022-07-11
22
-
23
17
  """This module implements all helpers for AWS Signature version '4' support."""
24
18
 
25
19
  from __future__ import absolute_import, annotations
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
3
  # (C) 2018 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -16,10 +14,6 @@
16
14
  # See the License for the specific language governing permissions and
17
15
  # limitations under the License.
18
16
 
19
- # NOTICE: This file has been changed and differs from the original
20
- # Author: L-ING
21
- # Date: 2022-07-11
22
-
23
17
  """This module contains core API parsers."""
24
18
  from __future__ import absolute_import, annotations
25
19
 
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,8 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
- # Asynchronous MinIO Client SDK for Python
3
- # (C) 2020 MinIO, Inc.
4
- # (C) 2022 Huseyn Mashadiyev <mashadiyev.huseyn@gmail.com>
5
- # (C) 2022 L-ING <hlf01@icloud.com>
2
+ # MinIO Python Library for Amazon S3 Compatible Cloud Storage, (C)
3
+ # 2020 MinIO, Inc.
6
4
  #
7
5
  # Licensed under the Apache License, Version 2.0 (the "License");
8
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "miniopy-async"
3
- version = "1.23.0"
3
+ version = "1.23.2"
4
4
  description = "Asynchronous MinIO Client SDK for Python"
5
5
  authors = [
6
6
  "L-ING <hlf01@icloud.com>",
@@ -25,7 +25,6 @@ package-mode = true
25
25
  [tool.poetry.dependencies]
26
26
  python = "^3.10"
27
27
  aiohttp = "^3.11.14"
28
- aiofile = "^3.9.0"
29
28
  certifi = "^2025.1.31"
30
29
  aiohttp-retry = "^2.9.1"
31
30
  argon2-cffi = "^23.1.0"
@@ -36,6 +35,7 @@ sanic = "^24.12.0"
36
35
  sanic-jinja2 = "^2022.11.11"
37
36
  sphinx = "8.1.3"
38
37
  sphinx-rtd-theme = "^3.0.2"
38
+ faker = "^37.4.0"
39
39
 
40
40
  [build-system]
41
41
  requires = ["poetry-core"]
File without changes
File without changes