Skip to content

Commit ed6444f

Browse files
committed
clean up docker_windows_path_adjust
1 parent 8f0eafc commit ed6444f

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

cwltool/utils.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,24 @@ def copytree_with_merge(src, dst, symlinks=False, ignore=None):
6161
shutil.copy2(s, d)
6262

6363

64-
# changes windowspath(only) appropriately to be passed to docker run command
65-
# as docker treat them as unix paths so convert C:\Users\foo to /C/Users/foo
6664
def docker_windows_path_adjust(path):
6765
# type: (Text) -> (Text)
66+
r"""
67+
Changes only windows paths so that the can be appropriately passed to the
68+
docker run command as as docker treats them as unix paths.
69+
70+
Example: 'C:\Users\foo to /C/Users/foo (Docker for Windows) or /c/Users/foo
71+
(Docker toolbox).
72+
"""
6873
if path is not None and onWindows():
69-
sp=path.split(':')
70-
if len(sp)==2:
71-
if platform.win32_ver()[0] < 9:
72-
sp[0]=sp[0].lower() # Docker toolbox uses lowecase windows Drive letters
74+
split = path.split(':')
75+
if len(split) == 2:
76+
if int(platform.win32_ver()[0]) < 9: # type: ignore
77+
split[0] = split[0].lower() # Docker toolbox uses lowecase windows Drive letters
7378
else:
74-
sp[0]=sp[0].capitalize() # Docker for Windows uses uppercase windows Drive letters
75-
path=':'.join(sp)
79+
split[0] = split[0].capitalize()
80+
# Docker for Windows uses uppercase windows Drive letters
81+
path = ':'.join(split)
7682
path = path.replace(':', '').replace('\\', '/')
7783
return path if path[0] == '/' else '/' + path
7884
return path

0 commit comments

Comments
 (0)