Skip to content

Commit 8c4927d

Browse files
committed
add black formatting and fix formating
1 parent 7ab15cc commit 8c4927d

File tree

3 files changed

+87
-10
lines changed

3 files changed

+87
-10
lines changed

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ dependencies = [
3333
[project.optional-dependencies]
3434
dev = [
3535
"pytest>=8.4.2",
36-
"pytest-cov>=7.0.0",
36+
"pytest-cov>=7.0.0",
37+
"black>=23.12.1",
3738
]
3839

3940
[project.scripts]

src/rasteret/cloud.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ def check_aws_credentials() -> bool:
6464
session = boto3.Session()
6565
credentials = session.get_credentials()
6666
if credentials is None:
67-
logger.info(
68-
"\nAWS credentials not found.\n"
69-
)
67+
logger.info("\nAWS credentials not found.\n")
7068
return False
7169
return True
7270
except Exception:
@@ -106,11 +104,16 @@ def _extract_s3_bucket_key(url: str) -> Optional[Tuple[str, str]]:
106104
host = p.netloc
107105
path = p.path.lstrip("/")
108106
# Virtual-hosted-style: <bucket>.s3.amazonaws.com or <bucket>.s3.<region>.amazonaws.com
109-
m = re.match(r"^([a-z0-9.\-]+)\.s3(?:[.-][a-z0-9-]+)?\.amazonaws\.com$", host)
107+
m = re.match(
108+
r"^([a-z0-9.\-]+)\.s3(?:[.-][a-z0-9-]+)?\.amazonaws\.com$", host
109+
)
110110
if m:
111111
return m.group(1), path
112112
# Path-style: s3.amazonaws.com/<bucket>/key or s3.<region>.amazonaws.com/<bucket>/key
113-
if re.match(r"^s3(?:[.-][a-z0-9-]+)?\.amazonaws\.com$", host) and "/" in path:
113+
if (
114+
re.match(r"^s3(?:[.-][a-z0-9-]+)?\.amazonaws\.com$", host)
115+
and "/" in path
116+
):
114117
bucket, key = path.split("/", 1)
115118
return bucket, key
116119
except Exception:
@@ -120,7 +123,11 @@ def _extract_s3_bucket_key(url: str) -> Optional[Tuple[str, str]]:
120123
def get_url(self, url: str, config: CloudConfig) -> Optional[str]:
121124
"""Resolve and sign URL based on configuration."""
122125
# First check for alternate S3 URL in STAC metadata
123-
if isinstance(url, dict) and "alternate" in url and "s3" in url.get("alternate", {}):
126+
if (
127+
isinstance(url, dict)
128+
and "alternate" in url
129+
and "s3" in url.get("alternate", {})
130+
):
124131
s3_url = url["alternate"]["s3"]["href"]
125132
logger.debug(f"Using alternate S3 URL: {s3_url}")
126133
url = s3_url
@@ -141,8 +148,12 @@ def get_url(self, url: str, config: CloudConfig) -> Optional[str]:
141148
bucket, key = bucket_key
142149
try:
143150
# Requester-pays requires signing and RequestPayer header
144-
if not getattr(self, "_have_creds", False) or not getattr(self, "client", None):
145-
logger.error("AWS credentials/client not available for requester-pays signing")
151+
if not getattr(self, "_have_creds", False) or not getattr(
152+
self, "client", None
153+
):
154+
logger.error(
155+
"AWS credentials/client not available for requester-pays signing"
156+
)
146157
return None
147158
params = {"Bucket": bucket, "Key": key, "RequestPayer": "requester"}
148159
return self.client.generate_presigned_url(

uv.lock

Lines changed: 66 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)