pyaws-s3 1.0.10__py3-none-any.whl → 1.0.12__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.
- pyaws_s3/s3.py +50 -24
- {pyaws_s3-1.0.10.dist-info → pyaws_s3-1.0.12.dist-info}/METADATA +9 -1
- pyaws_s3-1.0.12.dist-info/RECORD +7 -0
- pyaws_s3-1.0.10.dist-info/RECORD +0 -7
- {pyaws_s3-1.0.10.dist-info → pyaws_s3-1.0.12.dist-info}/WHEEL +0 -0
- {pyaws_s3-1.0.10.dist-info → pyaws_s3-1.0.12.dist-info}/licenses/LICENSE.md +0 -0
- {pyaws_s3-1.0.10.dist-info → pyaws_s3-1.0.12.dist-info}/top_level.txt +0 -0
pyaws_s3/s3.py
CHANGED
@@ -8,7 +8,10 @@ import matplotlib.pyplot as plt
|
|
8
8
|
from plotly.graph_objs import Figure
|
9
9
|
from pandas.plotting import table
|
10
10
|
from typing import Any, Literal
|
11
|
-
from
|
11
|
+
from reportlab.lib.pagesizes import A4
|
12
|
+
from reportlab.pdfgen import canvas
|
13
|
+
from reportlab.lib.units import mm
|
14
|
+
from io import BytesIO
|
12
15
|
|
13
16
|
logger = logging.getLogger(__name__)
|
14
17
|
|
@@ -351,7 +354,7 @@ class S3Client:
|
|
351
354
|
logger.error(f"Error deleting files: {str(e)}")
|
352
355
|
raise Exception(f"Error deleting files: {str(e)}")
|
353
356
|
|
354
|
-
def upload_to_pdf(self, *args
|
357
|
+
def upload_to_pdf(self, *args: Any, **kwargs: Any) -> str:
|
355
358
|
"""
|
356
359
|
Export the given text as a PDF and upload it to the S3 bucket.
|
357
360
|
|
@@ -368,37 +371,60 @@ class S3Client:
|
|
368
371
|
text = args[0] if len(args) > 0 else None
|
369
372
|
object_name = args[1] if len(args) > 1 else None
|
370
373
|
else:
|
371
|
-
text = kwargs.get("text", None)
|
374
|
+
text = kwargs.get("text", None)
|
372
375
|
object_name = kwargs.get("object_name", None)
|
373
|
-
|
376
|
+
|
374
377
|
if text is None:
|
375
|
-
|
378
|
+
raise Exception("Text is None")
|
376
379
|
|
377
380
|
if object_name is None:
|
378
|
-
|
381
|
+
raise Exception("Object name is None")
|
379
382
|
|
380
383
|
mimetypes = "application/pdf"
|
381
384
|
s3_client = self._get_s3_client()
|
382
385
|
s3_resource = self._get_s3_resource()
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
)
|
386
|
+
|
387
|
+
# Crea il PDF in memoria
|
388
|
+
pdf_buffer = BytesIO()
|
389
|
+
c = canvas.Canvas(pdf_buffer, pagesize=A4)
|
390
|
+
width, height = A4
|
391
|
+
c.setFont("Helvetica", 10)
|
392
|
+
x_margin = 20 * mm
|
393
|
+
y = height - 20 * mm
|
394
|
+
|
395
|
+
for line in text.strip().split('\n'):
|
396
|
+
line = line.strip()
|
397
|
+
if y < 20 * mm:
|
398
|
+
c.showPage()
|
399
|
+
c.setFont("Helvetica", 10)
|
400
|
+
y = height - 20 * mm
|
401
|
+
|
402
|
+
# Markdown-style header detection
|
403
|
+
if line.startswith("### "):
|
404
|
+
c.setFont("Helvetica-Bold", 11)
|
405
|
+
line = line[4:]
|
406
|
+
elif line.startswith("## "):
|
407
|
+
c.setFont("Helvetica-Bold", 12)
|
408
|
+
line = line[3:]
|
409
|
+
elif line.startswith("# "):
|
410
|
+
c.setFont("Helvetica-Bold", 14)
|
411
|
+
line = line[2:]
|
412
|
+
else:
|
413
|
+
c.setFont("Helvetica", 10)
|
414
|
+
|
415
|
+
c.drawString(x_margin, y, line)
|
416
|
+
y -= 12
|
417
|
+
|
418
|
+
c.save()
|
419
|
+
pdf_buffer.seek(0)
|
420
|
+
|
421
|
+
# Upload su S3
|
422
|
+
s3_resource.Bucket(self.bucket_name).Object(object_name).put(
|
423
|
+
Body=pdf_buffer,
|
424
|
+
ContentType=mimetypes
|
425
|
+
)
|
401
426
|
return self._create_url(s3_client, self.bucket_name, object_name)
|
427
|
+
|
402
428
|
except Exception as e:
|
403
429
|
logger.error(f"Error exporting PDF: {str(e)}")
|
404
430
|
raise Exception(f"Error exporting PDF: {str(e)}")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: pyaws_s3
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.12
|
4
4
|
Summary: A Python package for AWS S3 utilities
|
5
5
|
Author-email: Giuseppe Zileni <giuseppe.zileni@gmail.com>
|
6
6
|
Keywords: aws,s3,utilities
|
@@ -19,12 +19,15 @@ Requires-Dist: aiosignal==1.3.2
|
|
19
19
|
Requires-Dist: attrs==25.3.0
|
20
20
|
Requires-Dist: boto3==1.37.3
|
21
21
|
Requires-Dist: botocore==1.37.3
|
22
|
+
Requires-Dist: build==1.2.2.post1
|
23
|
+
Requires-Dist: chardet==5.2.0
|
22
24
|
Requires-Dist: contourpy==1.3.2
|
23
25
|
Requires-Dist: cycler==0.12.1
|
24
26
|
Requires-Dist: fonttools==4.58.0
|
25
27
|
Requires-Dist: fpdf==1.7.2
|
26
28
|
Requires-Dist: frozenlist==1.6.0
|
27
29
|
Requires-Dist: idna==3.10
|
30
|
+
Requires-Dist: iniconfig==2.1.0
|
28
31
|
Requires-Dist: jmespath==1.0.1
|
29
32
|
Requires-Dist: kiwisolver==1.4.8
|
30
33
|
Requires-Dist: matplotlib==3.10.3
|
@@ -35,11 +38,16 @@ Requires-Dist: packaging==23.2
|
|
35
38
|
Requires-Dist: pandas==2.2.3
|
36
39
|
Requires-Dist: pillow==11.2.1
|
37
40
|
Requires-Dist: plotly==6.1.0
|
41
|
+
Requires-Dist: pluggy==1.6.0
|
38
42
|
Requires-Dist: propcache==0.3.1
|
39
43
|
Requires-Dist: pyparsing==3.2.3
|
44
|
+
Requires-Dist: pyproject_hooks==1.2.0
|
45
|
+
Requires-Dist: pytest==8.3.5
|
40
46
|
Requires-Dist: python-dateutil==2.9.0.post0
|
41
47
|
Requires-Dist: pytz==2025.2
|
48
|
+
Requires-Dist: reportlab==4.4.1
|
42
49
|
Requires-Dist: s3transfer==0.11.3
|
50
|
+
Requires-Dist: setuptools==80.7.1
|
43
51
|
Requires-Dist: six==1.17.0
|
44
52
|
Requires-Dist: tzdata==2025.2
|
45
53
|
Requires-Dist: urllib3==2.4.0
|
@@ -0,0 +1,7 @@
|
|
1
|
+
pyaws_s3/__init__.py,sha256=Tr7xJiCKOMWYydOJ4kxHlA7AR1X3pRsJ8MjxJev2wsw,24
|
2
|
+
pyaws_s3/s3.py,sha256=ZkYeD96LeoovDHR49G9LE1jhCssAN_bObmG9n85euWI,19723
|
3
|
+
pyaws_s3-1.0.12.dist-info/licenses/LICENSE.md,sha256=7WXohDebeZpcVn_nH2aIaLhFZRvZBdcPSqWsO12lhwM,1074
|
4
|
+
pyaws_s3-1.0.12.dist-info/METADATA,sha256=p-RlVIVY4nqB0b6eS6AXPIgmsyvMBRlAPZewHOaV2C4,5493
|
5
|
+
pyaws_s3-1.0.12.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
6
|
+
pyaws_s3-1.0.12.dist-info/top_level.txt,sha256=MxSSC4Q8Vr32wKgrUAlwT4BTXwqUaG_CAWoBuPeXYjQ,9
|
7
|
+
pyaws_s3-1.0.12.dist-info/RECORD,,
|
pyaws_s3-1.0.10.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
pyaws_s3/__init__.py,sha256=Tr7xJiCKOMWYydOJ4kxHlA7AR1X3pRsJ8MjxJev2wsw,24
|
2
|
-
pyaws_s3/s3.py,sha256=oBG4-_Uk2uNI9ZuzGbmZl9eydbjErI-XW6cT-SFcy_s,18999
|
3
|
-
pyaws_s3-1.0.10.dist-info/licenses/LICENSE.md,sha256=7WXohDebeZpcVn_nH2aIaLhFZRvZBdcPSqWsO12lhwM,1074
|
4
|
-
pyaws_s3-1.0.10.dist-info/METADATA,sha256=2CUAzGGvq__e4jT-W-swTiWP9B6z-jbDr9ishaAAEmg,5235
|
5
|
-
pyaws_s3-1.0.10.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
|
6
|
-
pyaws_s3-1.0.10.dist-info/top_level.txt,sha256=MxSSC4Q8Vr32wKgrUAlwT4BTXwqUaG_CAWoBuPeXYjQ,9
|
7
|
-
pyaws_s3-1.0.10.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|