mirror of
https://github.com/camptocamp/odoo-cloud-platform.git
synced 2026-06-24 08:47:40 +00:00
[MIG] attachment_s3: Migration to 18.0
This commit is contained in:
+11
-7
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user