databutton 0.37.8__py3-none-any.whl → 0.38.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.
@@ -1,3 +1,3 @@
1
- from . import auth
1
+ from . import auth, folder
2
2
 
3
- __all__ = ["auth"]
3
+ __all__ = ["auth", "folder"]
@@ -0,0 +1,3 @@
1
+ from .folder import download, upload
2
+
3
+ __all__ = ["upload", "download"]
@@ -0,0 +1,44 @@
1
+ import io
2
+ import os
3
+ import zipfile
4
+
5
+ import databutton as db
6
+
7
+
8
+ def zip_folder_to_bytes(folder_path: str) -> bytes:
9
+ """Zip the contents of a folder and return as bytes."""
10
+ zip_bytes = io.BytesIO() # Use BytesIO as a buffer
11
+ with zipfile.ZipFile(zip_bytes, "w", zipfile.ZIP_DEFLATED) as zipf:
12
+ for root, _, files in os.walk(folder_path):
13
+ for file in files:
14
+ file_path = os.path.join(root, file)
15
+ zipf.write(
16
+ file_path,
17
+ os.path.relpath(file_path, os.path.join(folder_path, "..")),
18
+ )
19
+ zip_bytes.seek(0) # Go to the start of the BytesIO buffer
20
+ return zip_bytes.getvalue()
21
+
22
+
23
+ def unzip_bytes_to_folder(bytes_data: bytes, extract_path: str):
24
+ """Unzip bytes into a folder."""
25
+ # Ensure the extraction path exists
26
+ os.makedirs(extract_path, exist_ok=True)
27
+ zip_bytes = io.BytesIO(bytes_data)
28
+ with zipfile.ZipFile(zip_bytes, "r") as zip_ref:
29
+ zip_ref.extractall(extract_path)
30
+
31
+
32
+ def upload(key: str, folder_path: str):
33
+ """Zip and upload a folder to blob storage."""
34
+ zipped_bytes = zip_folder_to_bytes(folder_path)
35
+ db.storage.binary.put(key, zipped_bytes)
36
+
37
+
38
+ def download(key: str, folder_path: str):
39
+ """Download and unzip a folder from blob storage."""
40
+ zipped_bytes = db.storage.binary.get(key)
41
+ if zipped_bytes is not None:
42
+ # Ensure the target folder exists before extraction
43
+ os.makedirs(folder_path, exist_ok=True)
44
+ unzip_bytes_to_folder(zipped_bytes, folder_path)
databutton/version.py CHANGED
@@ -5,4 +5,4 @@ This module contains project version information.
5
5
  .. moduleauthor:: Databutton <support@databutton.com>
6
6
  """
7
7
 
8
- __version__ = "0.37.8"
8
+ __version__ = "0.38.0"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: databutton
3
- Version: 0.37.8
3
+ Version: 0.38.0
4
4
  Summary: The CLI for databutton.com
5
5
  License: Databutton
6
6
  Author: Databutton
@@ -16,7 +16,7 @@ Requires-Dist: certifi (>=2022.12.7,<2023.0.0)
16
16
  Requires-Dist: chromadb (>=0.4.22,<0.5.0)
17
17
  Requires-Dist: cryptography (>=40.0.1,<41.0.0)
18
18
  Requires-Dist: httpx (>=0.20.0,<1)
19
- Requires-Dist: pandas (>=0.25,<3)
19
+ Requires-Dist: pandas[feather] (>=0.25,<3)
20
20
  Requires-Dist: pydantic (>=1,<3)
21
21
  Requires-Dist: tenacity (>=8.0.0,<9.0.0)
22
22
  Description-Content-Type: text/markdown
@@ -1,8 +1,10 @@
1
1
  databutton/__init__.py,sha256=h5GdA1J_7UCaGxMFbobohHAiweUvqhOnm7TQ7cPaeGU,418
2
2
  databutton/cachetools.py,sha256=soq0BDkE_YNaybBx-fI4pJ1x8k9KuotZ0f_OuZCCI9k,3554
3
- databutton/experimental/__init__.py,sha256=e2vI2X5xQxTPZtsiYXnO91y52BQ4tTx1zbbvDnFK8tk,39
3
+ databutton/experimental/__init__.py,sha256=S5AFlCNuvWf5HR2BUs_uzNd-GmjbpVm6eA__DLMUpPU,57
4
4
  databutton/experimental/auth/__init__.py,sha256=hqMbUs9GIVW-bJrayhWzdmSLkmU1wvFHDp6jMKwQrWc,73
5
5
  databutton/experimental/auth/get_user.py,sha256=qi6nkG35PRgeljV4J-cHdEE4nhfwJHOYv93tBXR5A9I,3314
6
+ databutton/experimental/folder/__init__.py,sha256=27dUyREJ-08xP4OmQUtAyWWz7_hWEat6ajqiJ2xgyeo,71
7
+ databutton/experimental/folder/folder.py,sha256=LjzUZiE4nbvk2164s0dKY-hssCuJz5rWdUSsiw-rmRA,1548
6
8
  databutton/internal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
9
  databutton/internal/auth.py,sha256=MY4S7Gvb6xufmZ0SssZka0eY_18lJbxHW61cHrisnro,3182
8
10
  databutton/internal/byteutils.py,sha256=2SYQxhbK1Kj__u_ap01kPpeb1b_bcZAXSz6aqWwetUA,740
@@ -22,8 +24,8 @@ databutton/secrets/__init__.py,sha256=sI0okrfRBs2l5tcLTrKc9uUfPVVRMM9D7WED8p226t
22
24
  databutton/secrets/secrets.py,sha256=pehXsD09iKTxHaNQJ6awvIHXgRXBJrf4Xhrc11ZUeOk,3427
23
25
  databutton/storage/__init__.py,sha256=7ZNd4eQQ7lYYIe1MqCuFbFF1aAVCuj2c_zmJfaPVlDY,252
24
26
  databutton/storage/storage.py,sha256=x9LTyoAfLTWFCoy7XhA0tVUTkjldx8gYax09RkhMR1Q,20369
25
- databutton/version.py,sha256=NZcgP3ieiynaLngkEJPA1A_OBcVcVEj1nmqyqoKWVFs,175
26
- databutton-0.37.8.dist-info/LICENSE,sha256=c7h4pcVZapFEmqWoRTRv_S1P_aibrtDobqmlR-QtMUk,45
27
- databutton-0.37.8.dist-info/METADATA,sha256=b_URw0kOu65AEt4GIMIWLUmmgt21bTfXCP34qZyP2rc,2744
28
- databutton-0.37.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
29
- databutton-0.37.8.dist-info/RECORD,,
27
+ databutton/version.py,sha256=nxbdNEKRX8YnlQvq3y9BsGGdJQZVOcowtLGPv4Q6zrw,175
28
+ databutton-0.38.0.dist-info/LICENSE,sha256=c7h4pcVZapFEmqWoRTRv_S1P_aibrtDobqmlR-QtMUk,45
29
+ databutton-0.38.0.dist-info/METADATA,sha256=30xJ0gxIGDrkcAq-m4lHtEE5YWrSc6Hch6DaDeO_nwU,2753
30
+ databutton-0.38.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
31
+ databutton-0.38.0.dist-info/RECORD,,