Skip to content

Commit

Permalink
Merge pull request #115 from common-workflow-language/skip_schemas
Browse files Browse the repository at this point in the history
Optional skip_schemas
  • Loading branch information
mr-c committed Jun 23, 2017
2 parents 5b3863a + e39018a commit d370602
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions schema_salad/ref_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def merge_properties(a, b): # type: (List[Any], List[Any]) -> Dict[Any, Any]
def SubLoader(loader): # type: (Loader) -> Loader
return Loader(loader.ctx, schemagraph=loader.graph,
foreign_properties=loader.foreign_properties, idx=loader.idx,
cache=loader.cache, fetcher_constructor=loader.fetcher_constructor)
cache=loader.cache, fetcher_constructor=loader.fetcher_constructor,
skip_schemas=loader.skip_schemas)

class Fetcher(object):
def fetch_text(self, url): # type: (unicode) -> unicode
Expand Down Expand Up @@ -179,7 +180,8 @@ def __init__(self,
idx=None, # type: Dict[unicode, Union[CommentedMap, CommentedSeq, unicode, None]]
cache=None, # type: Dict[unicode, Any]
session=None, # type: requests.sessions.Session
fetcher_constructor=None # type: Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher]
fetcher_constructor=None, # type: Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher]
skip_schemas=None # type: bool
):
# type: (...) -> None

Expand All @@ -205,6 +207,11 @@ def __init__(self,
else:
self.cache = {}

if skip_schemas is not None:
self.skip_schemas = skip_schemas
else:
self.skip_schemas = False

if session is None:
if "HOME" in os.environ:
self.session = CacheControl(
Expand Down Expand Up @@ -305,6 +312,8 @@ def add_namespaces(self, ns): # type: (Dict[unicode, unicode]) -> None

def add_schemas(self, ns, base_url):
# type: (Union[List[unicode], unicode], unicode) -> None
if self.skip_schemas:
return
for sch in aslist(ns):
fetchurl = self.fetcher.urljoin(base_url, sch)
if fetchurl not in self.cache:
Expand Down

0 comments on commit d370602

Please sign in to comment.