From dd8916e7a13a9aaaa3243fc9827615706eeff992 Mon Sep 17 00:00:00 2001 From: jacobi petrucciani Date: Tue, 27 Aug 2024 15:36:28 -0400 Subject: [PATCH] bump python versions, fix formatting --- .github/workflows/test.yml | 2 +- README.md | 2 +- bucketstore.py | 26 ++++++-------------------- pyproject.toml | 3 --- 4 files changed, 8 insertions(+), 25 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d6908f1..e9c6406 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: needs: [ruff, black] strategy: matrix: - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] + python-version: ['3.10', '3.11', '3.12'] name: python ${{ matrix.python-version }} tests steps: - uses: actions/checkout@v4.1.7 diff --git a/README.md b/README.md index 480fde7..a57cc4c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![PyPI version](https://badge.fury.io/py/bucketstore.svg)](https://badge.fury.io/py/bucketstore) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) -[![Python 3.7+ supported](https://img.shields.io/badge/python-3.7+-blue.svg)](https://www.python.org/downloads/release/python-370/) +[![Python 3.10+ supported](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/release/python-3100/) **bucketstore** is a very simple Amazon S3 client, written in Python. It aims to be much more straight-forward to use than boto3, and specializes diff --git a/bucketstore.py b/bucketstore.py index 0595f17..8ac4cad 100644 --- a/bucketstore.py +++ b/bucketstore.py @@ -74,9 +74,7 @@ def set(self, value: str, metadata: dict = None, content_type: str = "") -> dict """Sets the key to the given value.""" if not metadata: metadata = {} - return self._boto_object.put( - Body=value, Metadata=metadata, ContentType=content_type - ) + return self._boto_object.put(Body=value, Metadata=metadata, ContentType=content_type) def rename(self, new_name: str) -> None: """renames the key to a given new name""" @@ -99,10 +97,7 @@ def delete( def is_public(self) -> bool: """returns True if the public-read ACL is set for the Key.""" for grant in self._boto_object.Acl().grants: - if ( - "AllUsers" in grant["Grantee"].get("URI", "") - and grant["Permission"] == "READ" - ): + if "AllUsers" in grant["Grantee"].get("URI", "") and grant["Permission"] == "READ": return True return False @@ -158,12 +153,8 @@ def __init__( self.name = name self.region = region or os.getenv("AWS_DEFAULT_REGION", AWS_DEFAULT_REGION) env_endpoint_url = os.getenv("AWS_ENDPOINT_URL", "") - self.endpoint_url = ( - endpoint_url or env_endpoint_url if env_endpoint_url else None - ) - self._boto_s3 = boto3.resource( - "s3", self.region, endpoint_url=self.endpoint_url - ) + self.endpoint_url = endpoint_url or env_endpoint_url if env_endpoint_url else None + self._boto_s3 = boto3.resource("s3", self.region, endpoint_url=self.endpoint_url) self._boto_bucket = self._boto_s3.Bucket(self.name) # Check if the bucket exists. @@ -216,10 +207,7 @@ def list(self, prefix: str = None, legacy_api: bool = False) -> List: def is_public(self) -> bool: """returns True if the public-read ACL is set for the bucket.""" for grant in self._boto_bucket.Acl().grants: - if ( - "AllUsers" in grant["Grantee"].get("URI", "") - and grant["Permission"] == "READ" - ): + if "AllUsers" in grant["Grantee"].get("URI", "") and grant["Permission"] == "READ": return True return False @@ -241,9 +229,7 @@ def get(self, key: str) -> str: selected_key = self.key(key) return selected_key.get() - def set( - self, key: str, value: str, metadata: dict = None, content_type: str = "" - ) -> dict: + def set(self, key: str, value: str, metadata: dict = None, content_type: str = "") -> dict: """creates/edits a key in the s3 bucket""" if not metadata: metadata = {} diff --git a/pyproject.toml b/pyproject.toml index ba9259e..67d3222 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,9 +10,6 @@ repository = "https://github.com/jpetrucciani/bucketstore" classifiers = [ "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12",