Python jsonschema.exceptions.RefResolutionError() Examples
The following are 20
code examples of jsonschema.exceptions.RefResolutionError().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
jsonschema.exceptions
, or try the search function
.
Example #1
Source File: validators.py From accelerated-data-lake with Apache License 2.0 | 5 votes |
def resolve_from_url(self, url): url, fragment = urldefrag(url) try: document = self.store[url] except KeyError: try: document = self.resolve_remote(url) except Exception as exc: raise RefResolutionError(exc) return self.resolve_fragment(document, fragment)
Example #2
Source File: validators.py From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal | 5 votes |
def resolve_fragment(self, document, fragment): """ Resolve a ``fragment`` within the referenced ``document``. :argument document: the referrant document :argument str fragment: a URI fragment to resolve within it """ fragment = fragment.lstrip(u"/") parts = unquote(fragment).split(u"/") if fragment else [] for part in parts: part = part.replace(u"~1", u"/").replace(u"~0", u"~") if isinstance(document, Sequence): # Array indexes should be turned into integers try: part = int(part) except ValueError: pass try: document = document[part] except (TypeError, LookupError): raise RefResolutionError( "Unresolvable JSON pointer: %r" % fragment ) return document
Example #3
Source File: validators.py From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal | 5 votes |
def resolve_from_url(self, url): url, fragment = urldefrag(url) try: document = self.store[url] except KeyError: try: document = self.resolve_remote(url) except Exception as exc: raise RefResolutionError(exc) return self.resolve_fragment(document, fragment)
Example #4
Source File: validators.py From SA-ctf_scoreboard with Creative Commons Zero v1.0 Universal | 5 votes |
def pop_scope(self): try: self._scopes_stack.pop() except IndexError: raise RefResolutionError( "Failed to pop the scope from an empty stack. " "`pop_scope()` should only be called once for every " "`push_scope()`", )
Example #5
Source File: test_data_loaders.py From cloudformation-cli with Apache License 2.0 | 5 votes |
def test_load_resource_spec_invalid_ref(): copy = json.loads(json.dumps(BASIC_SCHEMA)) copy["properties"]["foo"] = {"$ref": "#/bar"} with pytest.raises(SpecValidationError) as excinfo: load_resource_spec(json_s(copy)) cause = excinfo.value.__cause__ assert cause assert isinstance(cause, RefResolutionError) assert "bar" in str(cause)
Example #6
Source File: data_loaders.py From cloudformation-cli with Apache License 2.0 | 5 votes |
def load_resource_spec(resource_spec_file): # noqa: C901 """Load a resource provider definition from a file, and validate it.""" try: resource_spec = json.load(resource_spec_file) except ValueError as e: LOG.debug("Resource spec decode failed", exc_info=True) raise SpecValidationError(str(e)) from e validator = make_resource_validator() try: validator.validate(resource_spec) except ValidationError as e: LOG.debug("Resource spec validation failed", exc_info=True) raise SpecValidationError(str(e)) from e # TODO: more general validation framework if "remote" in resource_spec: raise SpecValidationError( "Property 'remote' is reserved for CloudFormation use" ) try: base_uri = resource_spec["$id"] except KeyError: base_uri = get_file_base_uri(resource_spec_file) inliner = RefInliner(base_uri, resource_spec) try: inlined = inliner.inline() except RefResolutionError as e: LOG.debug("Resource spec validation failed", exc_info=True) raise SpecValidationError(str(e)) from e try: validator.validate(inlined) except ValidationError as e: LOG.debug("Inlined schema is no longer valid", exc_info=True) raise InternalError() from e return inlined
Example #7
Source File: validators.py From Requester with MIT License | 5 votes |
def resolve_fragment(self, document, fragment): """ Resolve a ``fragment`` within the referenced ``document``. Arguments: document: The referrant document fragment (str): a URI fragment to resolve within it """ fragment = fragment.lstrip(u"/") parts = unquote(fragment).split(u"/") if fragment else [] for part in parts: part = part.replace(u"~1", u"/").replace(u"~0", u"~") if isinstance(document, Sequence): # Array indexes should be turned into integers try: part = int(part) except ValueError: pass try: document = document[part] except (TypeError, LookupError): raise RefResolutionError( "Unresolvable JSON pointer: %r" % fragment ) return document
Example #8
Source File: validators.py From Requester with MIT License | 5 votes |
def resolve_from_url(self, url): url, fragment = urldefrag(url) try: document = self.store[url] except KeyError: try: document = self.resolve_remote(url) except Exception as exc: raise RefResolutionError(exc) return self.resolve_fragment(document, fragment)
Example #9
Source File: validators.py From Requester with MIT License | 5 votes |
def pop_scope(self): try: self._scopes_stack.pop() except IndexError: raise RefResolutionError( "Failed to pop the scope from an empty stack. " "`pop_scope()` should only be called once for every " "`push_scope()`" )
Example #10
Source File: validators.py From accelerated-data-lake with Apache License 2.0 | 5 votes |
def resolve_fragment(self, document, fragment): """ Resolve a ``fragment`` within the referenced ``document``. Arguments: document: The referrant document fragment (str): a URI fragment to resolve within it """ fragment = fragment.lstrip(u"/") parts = unquote(fragment).split(u"/") if fragment else [] for part in parts: part = part.replace(u"~1", u"/").replace(u"~0", u"~") if isinstance(document, Sequence): # Array indexes should be turned into integers try: part = int(part) except ValueError: pass try: document = document[part] except (TypeError, LookupError): raise RefResolutionError( "Unresolvable JSON pointer: %r" % fragment ) return document
Example #11
Source File: validators.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def pop_scope(self): try: self._scopes_stack.pop() except IndexError: raise RefResolutionError( "Failed to pop the scope from an empty stack. " "`pop_scope()` should only be called once for every " "`push_scope()`" )
Example #12
Source File: validators.py From accelerated-data-lake with Apache License 2.0 | 5 votes |
def pop_scope(self): try: self._scopes_stack.pop() except IndexError: raise RefResolutionError( "Failed to pop the scope from an empty stack. " "`pop_scope()` should only be called once for every " "`push_scope()`" )
Example #13
Source File: test_schema.py From flocker with Apache License 2.0 | 5 votes |
def test_resolvingRaisesError(self): """ The L{LocalRefResolver.resolving} context manager raises an exception when entered. """ resolver = LocalRefResolver(base_uri=b'', referrer={}) context = resolver.resolving(b'http://json-schema.org/schema') e = self.assertRaises(RefResolutionError, context.__enter__) self.assertIsInstance(e.args[0], SchemaNotProvided)
Example #14
Source File: validators.py From deepWordBug with Apache License 2.0 | 5 votes |
def resolve_fragment(self, document, fragment): """ Resolve a ``fragment`` within the referenced ``document``. Arguments: document: The referrant document fragment (str): a URI fragment to resolve within it """ fragment = fragment.lstrip(u"/") parts = unquote(fragment).split(u"/") if fragment else [] for part in parts: part = part.replace(u"~1", u"/").replace(u"~0", u"~") if isinstance(document, Sequence): # Array indexes should be turned into integers try: part = int(part) except ValueError: pass try: document = document[part] except (TypeError, LookupError): raise RefResolutionError( "Unresolvable JSON pointer: %r" % fragment ) return document
Example #15
Source File: validators.py From deepWordBug with Apache License 2.0 | 5 votes |
def resolve_from_url(self, url): url, fragment = urldefrag(url) try: document = self.store[url] except KeyError: try: document = self.resolve_remote(url) except Exception as exc: raise RefResolutionError(exc) return self.resolve_fragment(document, fragment)
Example #16
Source File: validators.py From deepWordBug with Apache License 2.0 | 5 votes |
def pop_scope(self): try: self._scopes_stack.pop() except IndexError: raise RefResolutionError( "Failed to pop the scope from an empty stack. " "`pop_scope()` should only be called once for every " "`push_scope()`" )
Example #17
Source File: validators.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def resolve_from_url(self, url): url, fragment = urldefrag(url) try: document = self.store[url] except KeyError: try: document = self.resolve_remote(url) except Exception as exc: raise RefResolutionError(exc) return self.resolve_fragment(document, fragment)
Example #18
Source File: validators.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def pop_scope(self): try: self._scopes_stack.pop() except IndexError: raise RefResolutionError( "Failed to pop the scope from an empty stack. " "`pop_scope()` should only be called once for every " "`push_scope()`" )
Example #19
Source File: validators.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def resolve_fragment(self, document, fragment): """ Resolve a ``fragment`` within the referenced ``document``. Arguments: document: The referrant document fragment (str): a URI fragment to resolve within it """ fragment = fragment.lstrip(u"/") parts = unquote(fragment).split(u"/") if fragment else [] for part in parts: part = part.replace(u"~1", u"/").replace(u"~0", u"~") if isinstance(document, Sequence): # Array indexes should be turned into integers try: part = int(part) except ValueError: pass try: document = document[part] except (TypeError, LookupError): raise RefResolutionError( "Unresolvable JSON pointer: %r" % fragment ) return document
Example #20
Source File: validators.py From misp42splunk with GNU Lesser General Public License v3.0 | 5 votes |
def resolve_from_url(self, url): url, fragment = urldefrag(url) try: document = self.store[url] except KeyError: try: document = self.resolve_remote(url) except Exception as exc: raise RefResolutionError(exc) return self.resolve_fragment(document, fragment)