diff options
author | Matthew Lemon <y@yulqen.org> | 2024-09-11 16:25:09 +0100 |
---|---|---|
committer | Matthew Lemon <y@yulqen.org> | 2024-09-11 16:25:09 +0100 |
commit | a7afbfd090c3f059eeb0fe1573ca56f4c4cb9867 (patch) | |
tree | 280ed18c3e4121c95515d92e90d0fee715116fdd /pyblackbird_cc/resources/s3.py | |
parent | b38e4abf1712cc69db6a164425a99e3cad6d138e (diff) |
Some formatting changes and calming down ruff slightly
Diffstat (limited to '')
-rw-r--r-- | pyblackbird_cc/resources/s3.py | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/pyblackbird_cc/resources/s3.py b/pyblackbird_cc/resources/s3.py index e9703ca..3693b55 100644 --- a/pyblackbird_cc/resources/s3.py +++ b/pyblackbird_cc/resources/s3.py @@ -38,7 +38,7 @@ def get_s3_client() -> Session.client: endpoint_url=settings.AWS_S3_ENDPOINT_URL, aws_access_key_id=settings.AWS_ACCESS_KEY_ID, aws_secret_access_key=settings.AWS_SECRET_ACCESS_KEY, - region_name=settings.AWS_S3_REGION_NAME + region_name=settings.AWS_S3_REGION_NAME, ) @@ -53,11 +53,7 @@ def upload_files_to_s3(files: Sequence, dir_name: str) -> None: s3_client = get_s3_client() for file in files: logging.info(f"Uploading {file.name} to S3") - s3_client.upload_fileobj( - file, - settings.AWS_STORAGE_BUCKET_NAME, - f"{dir_name}/{file.name}" - ) + s3_client.upload_fileobj(file, settings.AWS_STORAGE_BUCKET_NAME, f"{dir_name}/{file.name}") def upload_snapshotted_pages_to_s3(snapshotted_pages) -> bool: @@ -67,9 +63,7 @@ def upload_snapshotted_pages_to_s3(snapshotted_pages) -> bool: for img in snapshotted_pages[0]: logging.info(f"Uploading {img} to S3") s3_client.upload_file( - img, - settings.AWS_STORAGE_BUCKET_NAME, - f"snapshotted_pages/{Path(img).name}" + img, settings.AWS_STORAGE_BUCKET_NAME, f"snapshotted_pages/{Path(img).name}" ) return True if collection_type in ["MULTI_PDF_SINGLE_PAGE", "MULTI_PDF_MULTI_PAGE"]: @@ -77,9 +71,7 @@ def upload_snapshotted_pages_to_s3(snapshotted_pages) -> bool: for img in pdf: logging.info(f"Uploading {img} to S3") s3_client.upload_file( - img, - settings.AWS_STORAGE_BUCKET_NAME, - f"snapshotted_pages/{Path(img).name}" + img, settings.AWS_STORAGE_BUCKET_NAME, f"snapshotted_pages/{Path(img).name}" ) return True return False @@ -94,8 +86,8 @@ def upload_to_s3(pdf_files, thumbnail_files, snapshotted_pages) -> bool: :return: True if the files was uploaded, False otherwise """ try: - upload_files_to_s3(pdf_files, dir_name='pdfuploads') - upload_files_to_s3(thumbnail_files, dir_name='thumbnails') + upload_files_to_s3(pdf_files, dir_name="pdfuploads") + upload_files_to_s3(thumbnail_files, dir_name="thumbnails") return upload_snapshotted_pages_to_s3(snapshotted_pages) except ClientError: logging.exception("Error uploading files to S3") |