Skip to content

Commit

Permalink
bump python versions, fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jpetrucciani committed Aug 27, 2024
1 parent f22fd15 commit dd8916e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
26 changes: 6 additions & 20 deletions bucketstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand All @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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 = {}
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit dd8916e

Please sign in to comment.