Skip to content

Commit

Permalink
Merge pull request #113 from untzag/windows_path
Browse files Browse the repository at this point in the history
[MRG] windows directories
  • Loading branch information
betatim committed Oct 2, 2017
2 parents 8380888 + 3baaf3c commit cee0587
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
8 changes: 1 addition & 7 deletions osfclient/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,7 @@ def upload(args):
_, dir_name = os.path.split(args.source)

for root, _, files in os.walk(args.source):
# these are extra subdirectories we have walked into since the root
# directory, have to clean off leading slashes from their name
# for path.join() to work later on
subdir_path = root.replace(args.source, '')
if subdir_path.startswith('/'):
subdir_path = subdir_path[1:]

subdir_path = os.path.relpath(root, args.source)
for fname in files:
local_path = os.path.join(root, fname)
with open(local_path, 'rb') as fp:
Expand Down
2 changes: 1 addition & 1 deletion osfclient/models/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def create_file(self, path, fp, update=False):
path = norm_remote_path(path)

directory, fname = os.path.split(path)
directories = directory.split('/')
directories = directory.split(os.path.sep)
# navigate to the right parent object for our file
parent = self
for directory in directories:
Expand Down
8 changes: 4 additions & 4 deletions osfclient/tests/test_uploading.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def simple_getenv(key):
assert len(fake_open.mock_calls) == 4 + 4*2

fake_storage.assert_has_calls([
call.create_file('BAR/bar.txt', mock.ANY, update=False),
call.create_file('BAR/abc.txt', mock.ANY, update=False),
call.create_file('BAR/./bar.txt', mock.ANY, update=False),
call.create_file('BAR/./abc.txt', mock.ANY, update=False),
call.create_file('BAR/baz/bar.txt', mock.ANY, update=False),
call.create_file('BAR/baz/abc.txt', mock.ANY, update=False)
])
Expand Down Expand Up @@ -162,8 +162,8 @@ def simple_getenv(key):
assert len(fake_open.mock_calls) == 4 + 4*2

fake_storage.assert_has_calls([
call.create_file('BAR/foobar/bar.txt', mock.ANY, update=False),
call.create_file('BAR/foobar/abc.txt', mock.ANY, update=False),
call.create_file('BAR/foobar/./bar.txt', mock.ANY, update=False),
call.create_file('BAR/foobar/./abc.txt', mock.ANY, update=False),
call.create_file('BAR/foobar/baz/bar.txt', mock.ANY, update=False),
call.create_file('BAR/foobar/baz/abc.txt', mock.ANY, update=False)
])
Expand Down
2 changes: 1 addition & 1 deletion osfclient/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def norm_remote_path(path):
All remote paths are absolute.
"""
path = os.path.normpath(path)
if path.startswith('/'):
if path.startswith(os.path.sep):
return path[1:]
else:
return path
Expand Down

0 comments on commit cee0587

Please sign in to comment.