squarecloud-api 3.7.1__py3-none-any.whl → 3.7.2__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.
squarecloud/__init__.py CHANGED
@@ -21,4 +21,4 @@ from .data import (
21
21
  from .file import File
22
22
  from .http.endpoints import Endpoint
23
23
 
24
- __version__ = '3.7.1'
24
+ __version__ = '3.7.2'
squarecloud/data.py CHANGED
@@ -1,9 +1,12 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import os
4
+ import zipfile
3
5
  from datetime import datetime
4
6
  from typing import Any, Dict, Literal, Optional
5
7
 
6
8
  from ._internal.constants import USING_PYDANTIC
9
+ from .http import HTTPClient
7
10
 
8
11
  if USING_PYDANTIC:
9
12
  from pydantic.dataclasses import dataclass
@@ -213,7 +216,6 @@ class BackupInfo:
213
216
  key: str
214
217
 
215
218
 
216
- @dataclass(frozen=True)
217
219
  class Backup:
218
220
  """
219
221
  Backup data class
@@ -225,11 +227,21 @@ class Backup:
225
227
  :type key: str
226
228
  """
227
229
 
228
- url: str
229
- key: str
230
+ __slots__ = ('url', 'key')
231
+
232
+ def __init__(self, url: str, key: str):
233
+ self.url = url
234
+ self.key = key
230
235
 
231
236
  def to_dict(self):
232
- return self.__dict__.copy()
237
+ return {'url': self.url, 'key': self.key}
238
+
239
+ async def download(self, path: str = './') -> zipfile.ZipFile:
240
+ file_name = os.path.basename(self.url.split('?')[0])
241
+ content = await HTTPClient.fetch_backup_content(self.url)
242
+ with zipfile.ZipFile(f'{path}/{file_name}', 'w') as zip_file:
243
+ zip_file.writestr(f'{path}/{file_name}', content)
244
+ return zip_file
233
245
 
234
246
 
235
247
  @dataclass(frozen=True)
@@ -279,15 +291,15 @@ class FileInfo:
279
291
 
280
292
  :type type: Literal['file', 'directory']
281
293
  :type name: str
282
- :type size: confloat(ge=0)
283
- :type lastModified: conint(ge=0) | float
294
+ :type size: int
295
+ :type lastModified: int | float | None
284
296
  :type path: str
285
297
  """
286
298
 
287
299
  app_id: str
288
300
  type: Literal['file', 'directory']
289
301
  name: str
290
- lastModified: int | float
302
+ lastModified: int | float | None
291
303
  path: str
292
304
  size: int = 0
293
305
 
@@ -232,6 +232,12 @@ class HTTPClient:
232
232
  )
233
233
  return response
234
234
 
235
+ @classmethod
236
+ async def fetch_backup_content(cls, url: str) -> bytes:
237
+ async with aiohttp.ClientSession() as session:
238
+ async with session.get(url) as response:
239
+ return await response.read()
240
+
235
241
  async def fetch_user_info(self) -> Response:
236
242
  """
237
243
  Fetches user information and returns the response object
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: squarecloud-api
3
- Version: 3.7.1
3
+ Version: 3.7.2
4
4
  Summary: SquareCloud API wrapper
5
5
  Home-page: https://github.com/squarecloudofc/wrapper-api-py
6
6
  License: MIT
@@ -1,20 +1,20 @@
1
- squarecloud/__init__.py,sha256=4Jnt6WKXW6ZABGztIwdoVYwDOB_lcshSgRwRZiKIu8c,425
1
+ squarecloud/__init__.py,sha256=ZdytpfrWz7dDvVdoDcIj5kwiLn7PdxHYUsZSwW9U_VA,425
2
2
  squarecloud/_internal/constants.py,sha256=thIXe6892x87rIVFgfMVvtqwR9cyeWrWdlAU0WHq6Aw,83
3
3
  squarecloud/_internal/decorators.py,sha256=1fZzykpU7Xr_1xXQ4VBQl5yfFwOgUATIESkMUlNPL1Y,298
4
4
  squarecloud/app.py,sha256=gVbbuFWsbnndzzUU82k3-P2dTsCG9mH_o5S5bvhFBh0,19961
5
5
  squarecloud/client.py,sha256=V5l8fEoNq0Q0mMdRPYhmcvrh4cgetKRzQR0xSa5Jo1Q,30048
6
- squarecloud/data.py,sha256=p7xtUuzMY8CZk4w5IRiwBujOBDIziwKhjGYpuVHFr-s,7638
6
+ squarecloud/data.py,sha256=b17Gzqb-qheh4kuRMjp3YYSEOsVHmTDDd2osXeFdeqE,8127
7
7
  squarecloud/errors.py,sha256=qXEghyetl1QIYLatcBXJHlsNP0EKPvR6Dme3gL_W3lg,6226
8
8
  squarecloud/file.py,sha256=FLKmewbQVbHt2CZfnvIyEGjQbyCNhlyrHi_rwTPMEyE,1868
9
9
  squarecloud/http/__init__.py,sha256=_EV2wzT4XxDaA4TAJgi8TfMfnB0kzhHtDVppLXyOxRs,78
10
10
  squarecloud/http/endpoints.py,sha256=M-4cyucX5TSEgVfPObSEjpXqLuwbvcn33FUXhU_oCJk,9708
11
- squarecloud/http/http_client.py,sha256=GTJA-j31FImS2jIVQJrfJIvJ4nUvKJgC--HEt2OK28U,29183
11
+ squarecloud/http/http_client.py,sha256=bZNmSfLg1FA2YQVBH9M0wuccATgA6i-2YEY6zSR8JEY,29414
12
12
  squarecloud/listeners/__init__.py,sha256=Qyi9LYhFi9Imnq2n3JsErtUXg85rEFsUjJqrPlqecJM,5052
13
13
  squarecloud/listeners/capture_listener.py,sha256=LXa597ErYZjsKZjGlB_Tf52j_yZZIe1nttAXa5dWzeM,5198
14
14
  squarecloud/listeners/request_listener.py,sha256=eax4-RPMV1dTE9ZmttP3g3G4lvVArJz2-W9hSoQRBxo,3869
15
15
  squarecloud/logging.py,sha256=fx012uU44E75dfDQsUqb-sVTw_I8by-MciB3b_dNSPI,1718
16
16
  squarecloud/utils.py,sha256=pJ1iyFTYwTVYgeWAyItOy8lncvZDpFKW4Hw0Ab8k3qw,2507
17
- squarecloud_api-3.7.1.dist-info/LICENSE,sha256=5-liL39HIvazSPlP2kIt394DB4Asv7Qw6Jv66kv_Wc4,1081
18
- squarecloud_api-3.7.1.dist-info/METADATA,sha256=KTeg9kEp0bA03sFjfaiaN5RL5cr8Ug3fA4c_Yz0WeTY,2402
19
- squarecloud_api-3.7.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
20
- squarecloud_api-3.7.1.dist-info/RECORD,,
17
+ squarecloud_api-3.7.2.dist-info/LICENSE,sha256=5-liL39HIvazSPlP2kIt394DB4Asv7Qw6Jv66kv_Wc4,1081
18
+ squarecloud_api-3.7.2.dist-info/METADATA,sha256=_TJkp88O8Tow88-dO2vo9cCWoxBHrolhV012fqycJh4,2402
19
+ squarecloud_api-3.7.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
20
+ squarecloud_api-3.7.2.dist-info/RECORD,,