@@ -377,20 +377,29 @@ def _find_bucket_key(self, s3_path):
377377 It will return the bucket and the key represented by the s3 path
378378 """
379379
380- _S3_ACCESSPOINT_TO_BUCKET_KEY_REGEX = re .compile (
381- r"^(?P<bucket>arn:(aws).*:s3:[a-z\-0-9]*:[0-9]{12}:accesspoint[:/][^/]+)/?"
382- r"(?P<key>.*)$"
383- )
384- _S3_OUTPOST_TO_BUCKET_KEY_REGEX = re .compile (
385- r"^(?P<bucket>arn:(aws).*:s3-outposts:[a-z\-0-9]+:[0-9]{12}:outpost[/:]"
386- r"[a-zA-Z0-9\-]{1,63}[/:](bucket|accesspoint)[/:][a-zA-Z0-9\-]{1,63})[/:]?(?P<key>.*)$"
387- )
388- match = _S3_ACCESSPOINT_TO_BUCKET_KEY_REGEX .match (s3_path )
389- if match :
390- return match .group ("bucket" ), match .group ("key" )
391- match = _S3_OUTPOST_TO_BUCKET_KEY_REGEX .match (s3_path )
392- if match :
393- return match .group ("bucket" ), match .group ("key" )
380+ bucket_format_list = [
381+ re .compile (
382+ r"^(?P<bucket>arn:(aws).*:s3:[a-z\-0-9]*:[0-9]{12}:accesspoint[:/][^/]+)/?"
383+ r"(?P<key>.*)$"
384+ ),
385+ re .compile (
386+ r"^(?P<bucket>arn:(aws).*:s3-outposts:[a-z\-0-9]+:[0-9]{12}:outpost[/:]"
387+ r"[a-zA-Z0-9\-]{1,63}[/:](bucket|accesspoint)[/:][a-zA-Z0-9\-]{1,63})[/:]?(?P<key>.*)$"
388+ ),
389+ re .compile (
390+ r"^(?P<bucket>arn:(aws).*:s3-outposts:[a-z\-0-9]+:[0-9]{12}:outpost[/:]"
391+ r"[a-zA-Z0-9\-]{1,63}[/:]bucket[/:]"
392+ r"[a-zA-Z0-9\-]{1,63})[/:]?(?P<key>.*)$"
393+ ),
394+ re .compile (
395+ r"^(?P<bucket>arn:(aws).*:s3-object-lambda:[a-z\-0-9]+:[0-9]{12}:"
396+ r"accesspoint[/:][a-zA-Z0-9\-]{1,63})[/:]?(?P<key>.*)$"
397+ ),
398+ ]
399+ for bucket_format in bucket_format_list :
400+ match = bucket_format .match (s3_path )
401+ if match :
402+ return match .group ("bucket" ), match .group ("key" )
394403 s3_components = s3_path .split ("/" , 1 )
395404 bucket = s3_components [0 ]
396405 s3_key = ""
@@ -1544,7 +1553,9 @@ async def _chmod(self, path, acl, recursive=False, **kwargs):
15441553 bucket , key , version_id = self .split_path (path )
15451554 if recursive :
15461555 allfiles = await self ._find (path , withdirs = False )
1547- await asyncio .gather (* [self ._chmod (p , acl , recursive = False ) for p in allfiles ])
1556+ await asyncio .gather (
1557+ * [self ._chmod (p , acl , recursive = False ) for p in allfiles ]
1558+ )
15481559 elif key :
15491560 if acl not in key_acls :
15501561 raise ValueError ("ACL not in %s" , key_acls )
0 commit comments