MCPcopy Create free account
hub / github.com/aws/aws-cli / find_bucket_key

Function find_bucket_key

awscli/customizations/s3/utils.py:219–237  ·  view source on GitHub ↗

This is a helper function that given an s3 path such that the path is of the form: bucket/key It will return the bucket and the key represented by the s3 path

(s3_path)

Source from the content-addressed store, hash-verified

217
218
219def find_bucket_key(s3_path):
220 """
221 This is a helper function that given an s3 path such that the path is of
222 the form: bucket/key
223 It will return the bucket and the key represented by the s3 path
224 """
225 block_unsupported_resources(s3_path)
226 match = _S3_ACCESSPOINT_TO_BUCKET_KEY_REGEX.match(s3_path)
227 if match:
228 return match.group('bucket'), match.group('key')
229 match = _S3_OUTPOST_TO_BUCKET_KEY_REGEX.match(s3_path)
230 if match:
231 return match.group('bucket'), match.group('key')
232 s3_components = s3_path.split('/', 1)
233 bucket = s3_components[0]
234 s3_key = ''
235 if len(s3_components) > 1:
236 s3_key = s3_components[1]
237 return bucket, s3_key
238
239
240def split_s3_bucket_key(s3_path):

Calls 2

matchMethod · 0.80