Skip to content

Commit 575f062

Browse files
committed
renamed pathFix to convert_pathsep_to_unix and moved it to utils
1 parent 4adfcb7 commit 575f062

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

cwltool/draft2tool.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
_logger_validation_warnings, compute_checksums,
2929
normalizeFilesDirs, shortname, uniquename)
3030
from .stdfsaccess import StdFsAccess
31-
from .utils import aslist, docker_windows_path_adjust, onWindows
31+
from .utils import aslist, docker_windows_path_adjust, convert_pathsep_to_unix
3232
from six.moves import map
3333

3434
ACCEPTLIST_EN_STRICT_RE = re.compile(r"^[a-zA-Z0-9._+-]+$")
@@ -107,7 +107,7 @@ def revmap_file(builder, outdir, f):
107107

108108
if "location" in f:
109109
if f["location"].startswith("file://"):
110-
path = pathFix(uri_file_path(f["location"]))
110+
path = convert_pathsep_to_unix(uri_file_path(f["location"]))
111111
revmap_f = builder.pathmapper.reversemap(path)
112112
if revmap_f:
113113
f["location"] = revmap_f[1]
@@ -133,12 +133,6 @@ def revmap_file(builder, outdir, f):
133133

134134
raise WorkflowException(u"Output File object is missing both `location` and `path` fields: %s" % f)
135135

136-
# On windows os.path.join would use backslash to join path, since we would use these paths in Docker we would convert it to /
137-
def pathFix(path): # type: (Text) -> (Text)
138-
if path is not None and onWindows():
139-
return path.replace('\\', '/')
140-
return path
141-
142136

143137
class CallbackJob(object):
144138
def __init__(self, job, output_callback, cachebuilder, jobcache):

cwltool/pathmapper.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from schema_salad.sourceline import SourceLine
1313
from six.moves import urllib
1414

15-
from .utils import onWindows
15+
from .utils import convert_pathsep_to_unix
1616

1717
from .stdfsaccess import StdFsAccess, abspath
1818

@@ -188,7 +188,8 @@ def visitlisting(self, listing, stagedir, basedir, copy=False, staged=False):
188188

189189
def visit(self, obj, stagedir, basedir, copy=False, staged=False):
190190
# type: (Dict[Text, Any], Text, Text, bool, bool) -> None
191-
tgt = self.pathFix(os.path.join(stagedir, obj["basename"]))
191+
tgt = convert_pathsep_to_unix(
192+
os.path.join(stagedir, obj["basename"]))
192193
if obj["location"] in self._pathmap:
193194
return
194195
if obj["class"] == "Directory":
@@ -249,8 +250,3 @@ def reversemap(self, target): # type: (Text) -> Tuple[Text, Text]
249250
return (k, v[0])
250251
return None
251252

252-
# On windows os.path.join would use backslash to join path, since we would use these paths in Docker we would convert it to /
253-
def pathFix(self,path): # type: (Text) -> (Text)
254-
if path is not None and onWindows():
255-
return path.replace('\\','/')
256-
return path

cwltool/utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ def onWindows():
111111
return os.name == 'nt'
112112

113113

114+
115+
# On windows os.path.join would use backslash to join path, since we would use these paths in Docker we would convert it to /
116+
def convert_pathsep_to_unix(path): # type: (Text) -> (Text)
117+
if path is not None and onWindows():
118+
return path.replace('\\', '/')
119+
return path
120+
114121
# comparision function to be used in sorting
115122
# python3 doesn't allow sorting of different
116123
# types like str() and int().

0 commit comments

Comments
 (0)