Skip to content

Commit e39018a

Browse files
committed
Optional skip_schemas
Fixes #433
1 parent 5b3863a commit e39018a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

schema_salad/ref_resolver.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def merge_properties(a, b): # type: (List[Any], List[Any]) -> Dict[Any, Any]
9797
def SubLoader(loader): # type: (Loader) -> Loader
9898
return Loader(loader.ctx, schemagraph=loader.graph,
9999
foreign_properties=loader.foreign_properties, idx=loader.idx,
100-
cache=loader.cache, fetcher_constructor=loader.fetcher_constructor)
100+
cache=loader.cache, fetcher_constructor=loader.fetcher_constructor,
101+
skip_schemas=loader.skip_schemas)
101102

102103
class Fetcher(object):
103104
def fetch_text(self, url): # type: (unicode) -> unicode
@@ -179,7 +180,8 @@ def __init__(self,
179180
idx=None, # type: Dict[unicode, Union[CommentedMap, CommentedSeq, unicode, None]]
180181
cache=None, # type: Dict[unicode, Any]
181182
session=None, # type: requests.sessions.Session
182-
fetcher_constructor=None # type: Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher]
183+
fetcher_constructor=None, # type: Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher]
184+
skip_schemas=None # type: bool
183185
):
184186
# type: (...) -> None
185187

@@ -205,6 +207,11 @@ def __init__(self,
205207
else:
206208
self.cache = {}
207209

210+
if skip_schemas is not None:
211+
self.skip_schemas = skip_schemas
212+
else:
213+
self.skip_schemas = False
214+
208215
if session is None:
209216
if "HOME" in os.environ:
210217
self.session = CacheControl(
@@ -305,6 +312,8 @@ def add_namespaces(self, ns): # type: (Dict[unicode, unicode]) -> None
305312

306313
def add_schemas(self, ns, base_url):
307314
# type: (Union[List[unicode], unicode], unicode) -> None
315+
if self.skip_schemas:
316+
return
308317
for sch in aslist(ns):
309318
fetchurl = self.fetcher.urljoin(base_url, sch)
310319
if fetchurl not in self.cache:

0 commit comments

Comments
 (0)