Skip to content

Commit 72af58e

Browse files
committed
URI / Path conversion enhanced
should work with win32 now
1 parent e085312 commit 72af58e

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

cwltool/load_tool.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
import logging
77
import re
88
import urlparse
9+
try:
10+
import pathlib
11+
except:
12+
import pathlib2 as pathlib
913

1014
from typing import Any, AnyStr, Callable, cast, Dict, Text, Tuple, Union
1115
from ruamel.yaml.comments import CommentedSeq, CommentedMap
1216
from avro.schema import Names
1317
import requests.sessions
1418

19+
1520
from schema_salad.ref_resolver import Loader, Fetcher
1621
import schema_salad.validate as validate
1722
from schema_salad.validate import ValidationException
@@ -42,7 +47,7 @@ def fetch_document(argsworkflow, # type: Union[Text, dict[Text, Any]]
4247
if split.scheme:
4348
uri = argsworkflow
4449
elif os.path.exists(os.path.abspath(argsworkflow)):
45-
uri = "file://" + os.path.abspath(argsworkflow)
50+
uri = pathlib.Path(os.path.abspath(argsworkflow)).as_uri()
4651
elif resolver:
4752
uri = resolver(document_loader, argsworkflow)
4853

cwltool/pathmapper.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import stat
44
import collections
55
import uuid
6+
import urllib
67
import urlparse
78
from functools import partial
89
from typing import Any, Callable, Set, Text, Tuple, Union
@@ -72,7 +73,7 @@ def addLocation(d):
7273

7374
def abspath(src, basedir): # type: (Text, Text) -> Text
7475
if src.startswith(u"file://"):
75-
ab = src[7:]
76+
ab = urllib.url2pathname(urlparse.urlparse(src).path)
7677
else:
7778
ab = src if os.path.isabs(src) else os.path.join(basedir, src)
7879
return ab

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ shellescape==3.4.1
66
schema-salad>=2.1.20161216210732,<3
77
cwltest>=1.0.20160907111242
88
typing==3.5.2.2 ; python_version>="2.7"
9+
pathlib2==2.1.0 ; python_version<"3.4"

0 commit comments

Comments
 (0)