Skip to content

Commit 597d92b

Browse files
authored
Merge pull request #256 from psafont/win32
Win32 compatibility
2 parents e085312 + 30e8126 commit 597d92b

File tree

6 files changed

+332
-3
lines changed

6 files changed

+332
-3
lines changed

cwltool/load_tool.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
import logging
77
import re
88
import urlparse
9+
import pathlib2
910

1011
from typing import Any, AnyStr, Callable, cast, Dict, Text, Tuple, Union
1112
from ruamel.yaml.comments import CommentedSeq, CommentedMap
1213
from avro.schema import Names
1314
import requests.sessions
1415

16+
1517
from schema_salad.ref_resolver import Loader, Fetcher
1618
import schema_salad.validate as validate
1719
from schema_salad.validate import ValidationException
@@ -42,7 +44,7 @@ def fetch_document(argsworkflow, # type: Union[Text, dict[Text, Any]]
4244
if split.scheme:
4345
uri = argsworkflow
4446
elif os.path.exists(os.path.abspath(argsworkflow)):
45-
uri = "file://" + os.path.abspath(argsworkflow)
47+
uri = pathlib2.Path(os.path.abspath(argsworkflow)).as_uri()
4648
elif resolver:
4749
uri = resolver(document_loader, argsworkflow)
4850

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

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
'shellescape >= 3.4.1, < 3.5',
5050
'schema-salad >= 2.1.20161216210732, < 3',
5151
'typing >= 3.5.2, < 3.6',
52-
'cwltest >= 1.0.20160907111242'],
52+
'cwltest >= 1.0.20160907111242',
53+
'pathlib2 >= 2.1.0'
54+
],
5355
test_suite='tests',
5456
tests_require=[],
5557
entry_points={

typeshed/2.7/pathlib2.pyi

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# Stubs for pathlib2 (Python 2)
2+
#
3+
# NOTE: This dynamically typed stub was automatically generated by stubgen.
4+
5+
from typing import Any, AnyStr, Type, TypeVar, Optional, Union
6+
from collections import Sequence
7+
8+
_P = TypeVar('_P', bound='PurePath')
9+
10+
intern = ... # type: Any
11+
basestring = ... # type: Any
12+
supports_symlinks = ... # type: bool
13+
nt = ... # type: Any
14+
15+
class _Flavour:
16+
join = ... # type: Any
17+
def __init__(self) -> None: ...
18+
def parse_parts(self, parts): ...
19+
def join_parsed_parts(self, drv, root, parts, drv2, root2, parts2): ...
20+
21+
class _WindowsFlavour(_Flavour):
22+
sep = ... # type: str
23+
altsep = ... # type: str
24+
has_drv = ... # type: bool
25+
pathmod = ... # type: Any
26+
is_supported = ... # type: Any
27+
drive_letters = ... # type: Any
28+
ext_namespace_prefix = ... # type: str
29+
reserved_names = ... # type: Any
30+
def splitroot(self, part, sep: Any = ...): ...
31+
def casefold(self, s): ...
32+
def casefold_parts(self, parts): ...
33+
def resolve(self, path): ...
34+
def is_reserved(self, parts): ...
35+
def make_uri(self, path): ...
36+
def gethomedir(self, username): ...
37+
38+
class _PosixFlavour(_Flavour):
39+
sep = ... # type: str
40+
altsep = ... # type: str
41+
has_drv = ... # type: bool
42+
pathmod = ... # type: Any
43+
is_supported = ... # type: Any
44+
def splitroot(self, part, sep: Any = ...): ...
45+
def casefold(self, s): ...
46+
def casefold_parts(self, parts): ...
47+
def resolve(self, path): ...
48+
def is_reserved(self, parts): ...
49+
def make_uri(self, path): ...
50+
def gethomedir(self, username): ...
51+
52+
class _Accessor: ...
53+
54+
class _NormalAccessor(_Accessor):
55+
stat = ... # type: Any
56+
lstat = ... # type: Any
57+
open = ... # type: Any
58+
listdir = ... # type: Any
59+
chmod = ... # type: Any
60+
lchmod = ... # type: Any
61+
#def lchmod(self, pathobj, mode): ...
62+
mkdir = ... # type: Any
63+
unlink = ... # type: Any
64+
rmdir = ... # type: Any
65+
rename = ... # type: Any
66+
replace = ... # type: Any
67+
symlink = ... # type: Any
68+
#def symlink(a, b, target_is_directory): ...
69+
#@staticmethod
70+
#def symlink(a, b, target_is_directory): ...
71+
utime = ... # type: Any
72+
def readlink(self, path): ...
73+
74+
class _Selector:
75+
child_parts = ... # type: Any
76+
successor = ... # type: Any
77+
def __init__(self, child_parts) -> None: ...
78+
def select_from(self, parent_path): ...
79+
80+
class _TerminatingSelector: ...
81+
82+
class _PreciseSelector(_Selector):
83+
name = ... # type: Any
84+
def __init__(self, name, child_parts) -> None: ...
85+
86+
class _WildcardSelector(_Selector):
87+
pat = ... # type: Any
88+
def __init__(self, pat, child_parts) -> None: ...
89+
90+
class _RecursiveWildcardSelector(_Selector):
91+
def __init__(self, pat, child_parts) -> None: ...
92+
93+
class _PathParents(Sequence):
94+
def __init__(self, path) -> None: ...
95+
def __len__(self): ...
96+
def __getitem__(self, idx): ...
97+
98+
class PurePath:
99+
def __new__(cls, *args): ...
100+
def __reduce__(self): ...
101+
def as_posix(self): ...
102+
def __bytes__(self): ...
103+
def as_uri(self) -> str: ...
104+
def __eq__(self, other): ...
105+
def __ne__(self, other): ...
106+
def __hash__(self): ...
107+
def __lt__(self, other): ...
108+
def __le__(self, other): ...
109+
def __gt__(self, other): ...
110+
def __ge__(self, other): ...
111+
drive = ... # type: Any
112+
root = ... # type: Any
113+
@property
114+
def anchor(self): ...
115+
@property
116+
def name(self): ...
117+
@property
118+
def suffix(self): ...
119+
@property
120+
def suffixes(self): ...
121+
@property
122+
def stem(self): ...
123+
def with_name(self, name): ...
124+
def with_suffix(self, suffix): ...
125+
def relative_to(self, *other): ...
126+
@property
127+
def parts(self): ...
128+
def joinpath(self, *args): ...
129+
def __truediv__(self, key): ...
130+
def __rtruediv__(self, key): ...
131+
__div__ = ... # type: Any
132+
__rdiv__ = ... # type: Any
133+
@property
134+
def parent(self): ...
135+
@property
136+
def parents(self): ...
137+
def is_absolute(self): ...
138+
def is_reserved(self): ...
139+
def match(self, path_pattern): ...
140+
141+
class PurePosixPath(PurePath): ...
142+
class PureWindowsPath(PurePath): ...
143+
144+
class Path(PurePath):
145+
def __new__(cls: Type[_P], *args: Union[AnyStr, PurePath],
146+
**kwargs: Any) -> _P: ...
147+
def __enter__(self): ...
148+
def __exit__(self, t, v, tb): ...
149+
@classmethod
150+
def cwd(cls): ...
151+
@classmethod
152+
def home(cls): ...
153+
def samefile(self, other_path): ...
154+
def iterdir(self): ...
155+
def glob(self, pattern): ...
156+
def rglob(self, pattern): ...
157+
def absolute(self): ...
158+
def resolve(self): ...
159+
def stat(self): ...
160+
def owner(self): ...
161+
def group(self): ...
162+
def open(self, mode: str = ..., buffering: int = ..., encoding: Optional[Any] = ..., errors: Optional[Any] = ..., newline: Optional[Any] = ...): ...
163+
def read_bytes(self): ...
164+
def read_text(self, encoding: Optional[Any] = ..., errors: Optional[Any] = ...): ...
165+
def write_bytes(self, data): ...
166+
def write_text(self, data, encoding: Optional[Any] = ..., errors: Optional[Any] = ...): ...
167+
def touch(self, mode: int = ..., exist_ok: bool = ...): ...
168+
def mkdir(self, mode: int = ..., parents: bool = ..., exist_ok: bool = ...): ...
169+
def chmod(self, mode): ...
170+
def lchmod(self, mode): ...
171+
def unlink(self): ...
172+
def rmdir(self): ...
173+
def lstat(self): ...
174+
def rename(self, target): ...
175+
def replace(self, target): ...
176+
def symlink_to(self, target, target_is_directory: bool = ...): ...
177+
def exists(self): ...
178+
def is_dir(self): ...
179+
def is_file(self): ...
180+
def is_symlink(self): ...
181+
def is_block_device(self): ...
182+
def is_char_device(self): ...
183+
def is_fifo(self): ...
184+
def is_socket(self): ...
185+
def expanduser(self): ...
186+
187+
class PosixPath(Path, PurePosixPath): ...
188+
class WindowsPath(Path, PureWindowsPath): ...

typeshed/2.7/urllib.pyi

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
# Stubs for urllib (Python 2)
2+
# NOTE: This dynamically typed stub was originally automatically generated by stubgen.
3+
4+
from typing import Any, AnyStr, Mapping, Union, Tuple, Sequence, IO
5+
6+
def url2pathname(pathname: AnyStr) -> AnyStr: ...
7+
def pathname2url(pathname: str) -> str: ...
8+
def urlopen(url: str, data=..., proxies: Mapping[str, str] = ..., context=...) -> IO[Any]: ...
9+
def urlretrieve(url, filename=..., reporthook=..., data=..., context=...): ...
10+
def urlcleanup() -> None: ...
11+
12+
class ContentTooShortError(IOError):
13+
content = ... # type: Any
14+
def __init__(self, message, content) -> None: ...
15+
16+
class URLopener:
17+
version = ... # type: Any
18+
proxies = ... # type: Any
19+
key_file = ... # type: Any
20+
cert_file = ... # type: Any
21+
context = ... # type: Any
22+
addheaders = ... # type: Any
23+
tempcache = ... # type: Any
24+
ftpcache = ... # type: Any
25+
def __init__(self, proxies: Mapping[str, str] = ..., context=..., **x509) -> None: ...
26+
def __del__(self): ...
27+
def close(self): ...
28+
def cleanup(self): ...
29+
def addheader(self, *args): ...
30+
type = ... # type: Any
31+
def open(self, fullurl: str, data=...): ...
32+
def open_unknown(self, fullurl, data=...): ...
33+
def open_unknown_proxy(self, proxy, fullurl, data=...): ...
34+
def retrieve(self, url, filename=..., reporthook=..., data=...): ...
35+
def open_http(self, url, data=...): ...
36+
def http_error(self, url, fp, errcode, errmsg, headers, data=...): ...
37+
def http_error_default(self, url, fp, errcode, errmsg, headers): ...
38+
def open_https(self, url, data=...): ...
39+
def open_file(self, url): ...
40+
def open_local_file(self, url): ...
41+
def open_ftp(self, url): ...
42+
def open_data(self, url, data=...): ...
43+
44+
class FancyURLopener(URLopener):
45+
auth_cache = ... # type: Any
46+
tries = ... # type: Any
47+
maxtries = ... # type: Any
48+
def __init__(self, *args, **kwargs) -> None: ...
49+
def http_error_default(self, url, fp, errcode, errmsg, headers): ...
50+
def http_error_302(self, url, fp, errcode, errmsg, headers, data=...): ...
51+
def redirect_internal(self, url, fp, errcode, errmsg, headers, data): ...
52+
def http_error_301(self, url, fp, errcode, errmsg, headers, data=...): ...
53+
def http_error_303(self, url, fp, errcode, errmsg, headers, data=...): ...
54+
def http_error_307(self, url, fp, errcode, errmsg, headers, data=...): ...
55+
def http_error_401(self, url, fp, errcode, errmsg, headers, data=...): ...
56+
def http_error_407(self, url, fp, errcode, errmsg, headers, data=...): ...
57+
def retry_proxy_http_basic_auth(self, url, realm, data=...): ...
58+
def retry_proxy_https_basic_auth(self, url, realm, data=...): ...
59+
def retry_http_basic_auth(self, url, realm, data=...): ...
60+
def retry_https_basic_auth(self, url, realm, data=...): ...
61+
def get_user_passwd(self, host, realm, clear_cache=...): ...
62+
def prompt_user_passwd(self, host, realm): ...
63+
64+
class ftpwrapper:
65+
user = ... # type: Any
66+
passwd = ... # type: Any
67+
host = ... # type: Any
68+
port = ... # type: Any
69+
dirs = ... # type: Any
70+
timeout = ... # type: Any
71+
refcount = ... # type: Any
72+
keepalive = ... # type: Any
73+
def __init__(self, user, passwd, host, port, dirs, timeout=..., persistent=...) -> None: ...
74+
busy = ... # type: Any
75+
ftp = ... # type: Any
76+
def init(self): ...
77+
def retrfile(self, file, type): ...
78+
def endtransfer(self): ...
79+
def close(self): ...
80+
def file_close(self): ...
81+
def real_close(self): ...
82+
83+
class addbase:
84+
fp = ... # type: Any
85+
read = ... # type: Any
86+
readline = ... # type: Any
87+
readlines = ... # type: Any
88+
fileno = ... # type: Any
89+
__iter__ = ... # type: Any
90+
next = ... # type: Any
91+
def __init__(self, fp) -> None: ...
92+
def close(self): ...
93+
94+
class addclosehook(addbase):
95+
closehook = ... # type: Any
96+
hookargs = ... # type: Any
97+
def __init__(self, fp, closehook, *hookargs) -> None: ...
98+
def close(self): ...
99+
100+
class addinfo(addbase):
101+
headers = ... # type: Any
102+
def __init__(self, fp, headers) -> None: ...
103+
def info(self): ...
104+
105+
class addinfourl(addbase):
106+
headers = ... # type: Any
107+
url = ... # type: Any
108+
code = ... # type: Any
109+
def __init__(self, fp, headers, url, code=...) -> None: ...
110+
def info(self): ...
111+
def getcode(self): ...
112+
def geturl(self): ...
113+
114+
def unwrap(url): ...
115+
def splittype(url): ...
116+
def splithost(url): ...
117+
def splituser(host): ...
118+
def splitpasswd(user): ...
119+
def splitport(host): ...
120+
def splitnport(host, defport=...): ...
121+
def splitquery(url): ...
122+
def splittag(url): ...
123+
def splitattr(url): ...
124+
def splitvalue(attr): ...
125+
def unquote(s: str) -> str: ...
126+
def unquote_plus(s: str) -> str: ...
127+
def quote(s: str, safe=...) -> str: ...
128+
def quote_plus(s: str, safe=...) -> str: ...
129+
def urlencode(query: Union[Sequence[Tuple[Any, Any]], Mapping[Any, Any]], doseq=...) -> str: ...
130+
131+
def getproxies() -> Mapping[str, str]: ...
132+
def proxy_bypass(host): ...
133+
134+
# Names in __all__ with no definition:
135+
# basejoin

0 commit comments

Comments
 (0)