pyaws-s3 1.0.0__py3-none-any.whl → 1.0.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.
@@ -0,0 +1,204 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyaws_s3
3
+ Version: 1.0.2
4
+ Summary: A Python package for AWS S3 utilities
5
+ Author: Giuseppe Zileni
6
+ Author-email: Giuseppe Zileni <giuseppe.zileni@gmail.com>
7
+ Keywords: aws,s3,utilities
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.12
11
+ Description-Content-Type: text/markdown
12
+ Requires-Dist: aioboto3==14.3.0
13
+ Requires-Dist: aiobotocore==2.22.0
14
+ Requires-Dist: aiofiles==24.1.0
15
+ Requires-Dist: aiohappyeyeballs==2.6.1
16
+ Requires-Dist: aiohttp==3.11.18
17
+ Requires-Dist: aioitertools==0.12.0
18
+ Requires-Dist: aiosignal==1.3.2
19
+ Requires-Dist: attrs==25.3.0
20
+ Requires-Dist: boto3==1.37.3
21
+ Requires-Dist: botocore==1.37.3
22
+ Requires-Dist: contourpy==1.3.2
23
+ Requires-Dist: cycler==0.12.1
24
+ Requires-Dist: fonttools==4.58.0
25
+ Requires-Dist: fpdf==1.7.2
26
+ Requires-Dist: frozenlist==1.6.0
27
+ Requires-Dist: idna==3.10
28
+ Requires-Dist: jmespath==1.0.1
29
+ Requires-Dist: kiwisolver==1.4.8
30
+ Requires-Dist: matplotlib==3.10.3
31
+ Requires-Dist: multidict==6.4.3
32
+ Requires-Dist: narwhals==1.39.1
33
+ Requires-Dist: numpy==2.2.5
34
+ Requires-Dist: packaging==25.0
35
+ Requires-Dist: pandas==2.2.3
36
+ Requires-Dist: pillow==11.2.1
37
+ Requires-Dist: plotly==6.1.0
38
+ Requires-Dist: propcache==0.3.1
39
+ Requires-Dist: pyparsing==3.2.3
40
+ Requires-Dist: python-dateutil==2.9.0.post0
41
+ Requires-Dist: pytz==2025.2
42
+ Requires-Dist: s3transfer==0.11.3
43
+ Requires-Dist: six==1.17.0
44
+ Requires-Dist: tzdata==2025.2
45
+ Requires-Dist: urllib3==2.4.0
46
+ Requires-Dist: wrapt==1.17.2
47
+ Requires-Dist: yarl==1.20.0
48
+ Dynamic: author
49
+ Dynamic: requires-python
50
+
51
+ # PYAWS_S3
52
+
53
+ ## Description
54
+
55
+ `S3Client` is a Python class that simplifies interaction with AWS S3 for uploading, downloading, managing, and deleting files. It supports uploading images, DataFrames, PDFs, generating pre-signed URLs, downloading files, listing files, and deleting individual files.
56
+
57
+ ## Installation
58
+
59
+ Make sure you have installed:
60
+
61
+ ```bash
62
+ pip install pyaws_s3
63
+ ```
64
+
65
+ ### Env Variables
66
+
67
+ Make sure to add these environment variables:
68
+
69
+ ```bash
70
+ AWS_ACCESS_KEY_ID=<Your Access Key Id>
71
+ AWS_SECRET_ACCESS_KEY=<Your Secret Access Key>
72
+ AWS_REGION=<Your Region>
73
+ AWS_BUCKET_NAME=<Your Bucket Name>
74
+ ```
75
+
76
+ ## Usage
77
+
78
+ ### Initialization
79
+
80
+ You can initialize the class by passing AWS credentials as parameters or via environment variables:
81
+
82
+ ```python
83
+ from s3_client import S3Client
84
+
85
+ s3 = S3Client(
86
+ aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),
87
+ aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),
88
+ region_name=os.getenv("AWS_REGION"),
89
+ bucket_name=os.getenv("AWS_BUCKET_NAME")
90
+ )
91
+ ```
92
+
93
+ ### Main Methods
94
+
95
+ #### 1. `upload_image(fig, object_name, format_file=Literal["png", "jpeg", "svg", "html"])`
96
+
97
+ Uploads a figure (e.g., Matplotlib or Plotly) to S3 as an image (svg, png, jpeg, html).
98
+
99
+ ```python
100
+ url = s3.upload_image(fig, "folder/image.svg", format_file="svg")
101
+ ```
102
+
103
+ #### 2. `upload_from_dataframe(df, object_name, format_file=Literal["xlsx", "csv", "pdf"])`
104
+
105
+ Uploads a DataFrame to S3 as an Excel, CSV, or PDF file.
106
+
107
+ ```python
108
+ url = s3.upload_from_dataframe(df, "folder/data", format_file="csv")
109
+ ```
110
+
111
+ #### 3. `upload_to_pdf(text, object_name)`
112
+
113
+ Exports text to PDF and uploads it to S3.
114
+
115
+ ```python
116
+ url = s3.upload_to_pdf("Text to export", "folder/file.pdf")
117
+ ```
118
+
119
+ #### 4. `await delete_all(filter=None)`
120
+
121
+ Deletes all files from the bucket, optionally filtering by name.
122
+
123
+ ```python
124
+ import asyncio
125
+ await s3.delete_all(filter="your_filter")
126
+ ```
127
+
128
+ #### 5. `download(object_name, local_path=None, stream=False)`
129
+
130
+ Downloads a file from the S3 bucket.
131
+
132
+ - `object_name` (str): The name of the S3 object to download.
133
+ - `local_path` (str, optional): Local path to save the downloaded file. Required if `stream` is False.
134
+ - `stream` (bool, optional): If True, returns the file content as bytes instead of saving locally.
135
+
136
+ **Examples:**
137
+
138
+ Download and save locally:
139
+
140
+ ```python
141
+ local_path = s3.download("folder/image.svg", local_path="downloads/image.svg")
142
+ ```
143
+
144
+ Download as bytes (stream):
145
+
146
+ ```python
147
+ file_bytes = s3.download("folder/image.svg", stream=True)
148
+ ```
149
+
150
+ #### 6. `list_files(filter=None) -> list[str]`
151
+
152
+ Lists all files in the S3 bucket, optionally filtered by a substring.
153
+
154
+ - `filter` (str, optional): Only files containing this substring will be listed.
155
+
156
+ **Example:**
157
+
158
+ ```python
159
+ files = s3.list_files(filter="folder/")
160
+ ```
161
+
162
+ #### 7. `delete_file(object_name)`
163
+
164
+ Deletes a single file from the S3 bucket.
165
+
166
+ - `object_name` (str): The name of the S3 object to delete.
167
+
168
+ **Example:**
169
+
170
+ ```python
171
+ s3.delete_file("folder/image.svg")
172
+ ```
173
+
174
+ ## Notes
175
+
176
+ - All upload methods return a pre-signed URL for downloading the file.
177
+ - Integrated error handling with logging.
178
+ - For uploading images and DataFrames, utility functions are required (`bytes_from_figure`, `html_from_figure`).
179
+
180
+ ## Complete Example
181
+
182
+ ```python
183
+ import matplotlib.pyplot as plt
184
+ import pandas as pd
185
+
186
+ fig, ax = plt.subplots()
187
+ ax.plot([1, 2, 3], [4, 5, 6])
188
+
189
+ df = pd.DataFrame({"a": [1, 2], "b": [3, 4]})
190
+
191
+ s3 = S3Client(bucket_name="my-bucket")
192
+ img_url = s3.upload_image(fig, "test.svg")
193
+ df_url = s3.upload_from_dataframe(df, "mydata")
194
+ pdf_url = s3.upload_to_pdf("Hello PDF", "hello.pdf")
195
+
196
+ # Download a file
197
+ local_path = s3.download("test.svg", local_path="downloads/test.svg")
198
+
199
+ # List files
200
+ files = s3.list_files()
201
+
202
+ # Delete a file
203
+ s3.delete_file("test.svg")
204
+ ```
@@ -0,0 +1,4 @@
1
+ pyaws_s3-1.0.2.dist-info/METADATA,sha256=AoMP7svciEiYRWpaF16y3yml_5J-TjdAah2BqB7U0h4,5261
2
+ pyaws_s3-1.0.2.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
3
+ pyaws_s3-1.0.2.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
+ pyaws_s3-1.0.2.dist-info/RECORD,,
@@ -1,49 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: pyaws_s3
3
- Version: 1.0.0
4
- Summary: A Python package for AWS S3 utilities
5
- Author: Giuseppe Zileni
6
- Author-email: Giuseppe Zileni <giuseppe.zileni@gmail.com>
7
- License: MIT
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: Operating System :: OS Independent
10
- Requires-Python: >=3.12
11
- Description-Content-Type: text/markdown
12
- Requires-Dist: aioboto3==14.3.0
13
- Requires-Dist: aiobotocore==2.22.0
14
- Requires-Dist: aiofiles==24.1.0
15
- Requires-Dist: aiohappyeyeballs==2.6.1
16
- Requires-Dist: aiohttp==3.11.18
17
- Requires-Dist: aioitertools==0.12.0
18
- Requires-Dist: aiosignal==1.3.2
19
- Requires-Dist: attrs==25.3.0
20
- Requires-Dist: boto3==1.37.3
21
- Requires-Dist: botocore==1.37.3
22
- Requires-Dist: contourpy==1.3.2
23
- Requires-Dist: cycler==0.12.1
24
- Requires-Dist: fonttools==4.58.0
25
- Requires-Dist: fpdf==1.7.2
26
- Requires-Dist: frozenlist==1.6.0
27
- Requires-Dist: idna==3.10
28
- Requires-Dist: jmespath==1.0.1
29
- Requires-Dist: kiwisolver==1.4.8
30
- Requires-Dist: matplotlib==3.10.3
31
- Requires-Dist: multidict==6.4.3
32
- Requires-Dist: narwhals==1.39.1
33
- Requires-Dist: numpy==2.2.5
34
- Requires-Dist: packaging==25.0
35
- Requires-Dist: pandas==2.2.3
36
- Requires-Dist: pillow==11.2.1
37
- Requires-Dist: plotly==6.1.0
38
- Requires-Dist: propcache==0.3.1
39
- Requires-Dist: pyparsing==3.2.3
40
- Requires-Dist: python-dateutil==2.9.0.post0
41
- Requires-Dist: pytz==2025.2
42
- Requires-Dist: s3transfer==0.11.3
43
- Requires-Dist: six==1.17.0
44
- Requires-Dist: tzdata==2025.2
45
- Requires-Dist: urllib3==2.4.0
46
- Requires-Dist: wrapt==1.17.2
47
- Requires-Dist: yarl==1.20.0
48
- Dynamic: author
49
- Dynamic: requires-python
@@ -1,4 +0,0 @@
1
- pyaws_s3-1.0.0.dist-info/METADATA,sha256=jwsrs5Xej4q1G08GjYU1-S9G0geqOZv3b74DSvM3ZxQ,1526
2
- pyaws_s3-1.0.0.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
3
- pyaws_s3-1.0.0.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
4
- pyaws_s3-1.0.0.dist-info/RECORD,,