Skip to content

Commit 2aecb05

Browse files
authored
Merge branch 'master' into pip-conflict-checker
2 parents 7a793ac + 999d689 commit 2aecb05

File tree

4 files changed

+200
-5
lines changed

4 files changed

+200
-5
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
typing==3.5.2.2 ; python_version>="2.7"
22
avro-python3 ; python_version>="3"
33
avro==1.8.1 ; python_version<"3"
4+
pathlib2==2.1.0
45
ruamel.yaml==0.12.4
56
rdflib==4.2.1
67
rdflib-jsonld==0.4.0

schema_salad/ref_resolver.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
import hashlib
55
import logging
66
import collections
7+
import urllib
78
import urlparse
89
import re
910
import copy
1011
import pprint
1112
from StringIO import StringIO
13+
import pathlib2
1214

1315
from . import validate
1416
from .aslist import aslist
@@ -108,7 +110,7 @@ def fetch_text(self, url):
108110
return resp.text
109111
elif scheme == 'file':
110112
try:
111-
with open(path) as fp:
113+
with open(urllib.url2pathname(str(urlparse.urlparse(url).path))) as fp:
112114
read = fp.read()
113115
if hasattr(read, "decode"):
114116
return read.decode("utf-8")
@@ -137,7 +139,7 @@ def check_exists(self, url): # type: (unicode) -> bool
137139
return False
138140
return True
139141
elif scheme == 'file':
140-
return os.path.exists(path)
142+
return os.path.exists(urllib.url2pathname(str(urlparse.urlparse(url).path)))
141143
else:
142144
raise ValueError('Unsupported scheme in url: %s' % url)
143145

@@ -371,13 +373,17 @@ def resolve_ref(self,
371373
checklinks=True # type: bool
372374
):
373375
# type: (...) -> Tuple[Union[CommentedMap, CommentedSeq, unicode], Dict[unicode, Any]]
374-
base_url = base_url or u'file://%s/' % os.path.abspath('.')
375376

376377
obj = None # type: CommentedMap
377378
resolved_obj = None # type: Union[CommentedMap, CommentedSeq, unicode]
378379
inc = False
379380
mixin = None # type: Dict[unicode, Any]
380381

382+
if not base_url:
383+
if isinstance(ref, unicode):
384+
ref = pathlib2.Path(os.path.join(os.getcwd(), ref)).as_uri()
385+
base_url = pathlib2.Path(os.getcwd()).as_uri() + '/'
386+
381387
sl = SourceLine(obj, None, ValueError)
382388
# If `ref` is a dict, look for special directives.
383389
if isinstance(ref, CommentedMap):
@@ -418,7 +424,6 @@ def resolve_ref(self,
418424
raise ValueError(u"Expected CommentedMap or string, got %s: `%s`" % (type(ref), unicode(ref)))
419425

420426
url = self.expand_url(ref, base_url, scoped_id=(obj is not None))
421-
422427
# Has this reference been loaded already?
423428
if url in self.idx and (not mixin):
424429
return self.idx[url], {}

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
'mistune >= 0.7.3, < 0.8',
3737
'typing >= 3.5.2, < 3.6',
3838
'CacheControl >= 0.11.7, < 0.12',
39-
'lockfile >= 0.9']
39+
'lockfile >= 0.9',
40+
'pathlib2 >= 2.1.0']
4041

4142
install_requires.append("avro") # TODO: remove me once cwltool is
4243
# available in Debian Stable, Ubuntu 12.04 LTS

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): ...

0 commit comments

Comments
 (0)