Commit 3ed43b0 1 parent 6d0019e commit 3ed43b0 Copy full SHA for 3ed43b0
File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -200,7 +200,15 @@ def profile(self) -> str | None:
200
200
201
201
@property
202
202
def bucket (self ) -> str :
203
- bucket = self ._uri .hostname
203
+ split = self ._uri .netloc .split ("@" )
204
+ num_components = len (split )
205
+ if num_components == 2 :
206
+ bucket = split [1 ]
207
+ elif num_components == 1 :
208
+ bucket = split [0 ]
209
+ else :
210
+ raise ValueError (f"Unexpected extra '@' in S3 URI: '{ str (self )} '" )
211
+
204
212
if not bucket :
205
213
raise ValueError (f"S3 URI does not include bucket name: '{ str (self )} '" )
206
214
Original file line number Diff line number Diff line change @@ -266,6 +266,23 @@ def test_s3_endpoint_url(self):
266
266
path .write (data )
267
267
self .assertEqual (path .read (), data )
268
268
269
+ def test_uri_syntax (self ):
270
+ path1 = ResourcePath ("s3://profile@bucket/path" )
271
+ self .assertEqual (path1 .bucket , "bucket" )
272
+ self .assertEqual (path1 .profile , "profile" )
273
+ path2 = ResourcePath ("s3://bucket2/path" )
274
+ self .assertEqual (path2 .bucket , "bucket2" )
275
+ self .assertEqual (path2 .profile , None )
276
+
277
+ def test_ceph_uri_syntax (self ):
278
+ # The Ceph S3 'multi-tenant' syntax for buckets can include colons.
279
+ path1 = ResourcePath ("s3://profile@ceph:bucket/path" )
280
+ self .assertEqual (path1 .bucket , "ceph:bucket" )
281
+ self .assertEqual (path1 .profile , "profile" )
282
+ path2 = ResourcePath ("s3://ceph:bucket2/path" )
283
+ self .assertEqual (path2 .bucket , "ceph:bucket2" )
284
+ self .assertEqual (path2 .profile , None )
285
+
269
286
270
287
if __name__ == "__main__" :
271
288
unittest .main ()
You can’t perform that action at this time.
0 commit comments