[MIG] attachment_s3: Migration to 18.0

This commit is contained in:
Maksym Yankin
2025-01-30 16:46:34 +02:00
parent 225cd56744
commit 34bd6693e0
4 changed files with 91 additions and 83 deletions
+11 -7
View File
@@ -2,19 +2,23 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)
import re
from typing import Optional
class S3Uri:
_url_re = re.compile("^s3:///*([^/]*)/?(.*)", re.IGNORECASE | re.UNICODE)
_url_re = re.compile(r"^s3://+([^/]+)/?(.*)", re.IGNORECASE | re.UNICODE)
def __init__(self, uri):
def __init__(self, uri: str) -> None:
match = self._url_re.match(uri)
if not match:
raise ValueError("%s: is not a valid S3 URI" % (uri,))
self._bucket, self._item = match.groups()
raise ValueError(f"{uri}: is not a valid S3 URI")
self._bucket: str = match.group(1)
self._item: Optional[str] = match.group(2) if match.group(2) else None
def bucket(self):
@property
def bucket(self) -> str:
return self._bucket
def item(self):
@property
def item(self) -> Optional[str]:
return self._item