Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions stor/obs.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ def resource(self):

return self.parts_class(joined_resource) if joined_resource else None

def splitdrive(self):
"""Split drive for obs paths from the rest"""
return self.path_class(self.drive), self[len(self.drive):]

def normpath(self):
"""Normalize path following linux conventions (keeps drive prefix)"""
normed = posixpath.normpath('/' + str(self)[len(self.drive):])[1:]
Expand Down
6 changes: 6 additions & 0 deletions stor/tests/test_dx_path_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,9 @@ def test_splitpath(self):
assert f.splitpath() == (DXCanonicalPath("dx://project-123456789012345678901234:"), '')
f = DXPath('dx://project-123456789012345678901234')
assert f.splitpath() == (DXCanonicalPath("dx://project-123456789012345678901234:"), '')

def test_splitdrive(self):
f = DXPath('dx://')
assert f.splitdrive() == (DXPath('dx://'), '')
f = DXPath('dx://project:prefix/dir/file')
assert f.splitdrive() == (DXPath('dx://'), 'project:prefix/dir/file')
6 changes: 6 additions & 0 deletions stor/tests/test_s3_path_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ def test_properties(self):
# .ext
self.assertEqual(f.ext, '.csv')
self.assertEqual(f.parent.ext, '')

def test_splitdrive(self):
f = S3Path('s3://')
assert f.splitdrive() == (S3Path('s3://'), '')
f = S3Path('s3://bucket/prefix/whatever.csv')
assert f.splitdrive() == (S3Path('s3://'), 'bucket/prefix/whatever.csv')
6 changes: 6 additions & 0 deletions stor/tests/test_swift_path_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,9 @@ def test_properties(self):
# .ext
self.assertEqual(f.ext, '.csv')
self.assertEqual(f.parent.ext, '')

def test_splitdrive(self):
f = SwiftPath("swift://")
assert f.splitdrive() == (SwiftPath('swift://'), '')
f = SwiftPath("swift://foo")
assert f.splitdrive() == (SwiftPath('swift://'), 'foo')