schema_salad.ref_resolver

Module Contents

Classes

NormDict

A Dict where all keys are normalized using the provided function.

Loader

Functions

file_uri(path[, split_frag])

uri_file_path(url)

to_validation_exception(e)

Convert ruamel.yaml exception to our type.

SubLoader(loader)

schema_salad.ref_resolver.file_uri(path, split_frag=False)
Parameters:
  • path (str) –

  • split_frag (bool) –

Return type:

str

schema_salad.ref_resolver.uri_file_path(url)
Parameters:

url (str) –

Return type:

str

schema_salad.ref_resolver.to_validation_exception(e)

Convert ruamel.yaml exception to our type.

Parameters:

e (ruamel.yaml.error.MarkedYAMLError) –

Return type:

schema_salad.exceptions.ValidationException

class schema_salad.ref_resolver.NormDict(normalize=str)

Bases: Dict[str, Union[ruamel.yaml.comments.CommentedMap, ruamel.yaml.comments.CommentedSeq, str, None]]

digraph inheritance5b4caf496b { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "Dict" [URL="https://docs.python.org/3/library/typing.html#typing.Dict",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "NormDict" [URL="#schema_salad.ref_resolver.NormDict",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A Dict where all keys are normalized using the provided function."]; "Dict" -> "NormDict" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

A Dict where all keys are normalized using the provided function.

Parameters:

normalize (Callable[[str], str]) –

__eq__(other)

Return self==value.

Parameters:

other (Any) –

Return type:

bool

__getitem__(key)

x.__getitem__(y) <==> x[y]

Parameters:

key (Any) –

Return type:

Any

__setitem__(key, value)

Set self[key] to value.

Parameters:
  • key (Any) –

  • value (Any) –

Return type:

Any

__delitem__(key)

Delete self[key].

Parameters:

key (Any) –

Return type:

Any

__contains__(key)

True if the dictionary has the specified key, else False.

Parameters:

key (Any) –

Return type:

bool

__del__()
Return type:

None

schema_salad.ref_resolver.SubLoader(loader)
Parameters:

loader (Loader) –

Return type:

Loader

class schema_salad.ref_resolver.Loader(ctx, schemagraph=None, foreign_properties=None, idx=None, cache=None, session=None, fetcher_constructor=None, skip_schemas=None, url_fields=None, allow_attachments=None, doc_cache=True, salad_version=None)
Parameters:
  • ctx (schema_salad.utils.ContextType) –

  • schemagraph (Optional[rdflib.graph.Graph]) –

  • foreign_properties (Optional[Set[str]]) –

  • idx (Optional[schema_salad.utils.IdxType]) –

  • cache (Optional[schema_salad.utils.CacheType]) –

  • session (Optional[requests.sessions.Session]) –

  • fetcher_constructor (Optional[schema_salad.utils.FetcherCallableType]) –

  • skip_schemas (Optional[bool]) –

  • url_fields (Optional[Set[str]]) –

  • allow_attachments (Optional[schema_salad.utils.AttachmentsType]) –

  • doc_cache (Union[str, bool]) –

  • salad_version (Optional[str]) –

expand_url(url, base_url, scoped_id=False, vocab_term=False, scoped_ref=None)
Parameters:
  • url (str) –

  • base_url (str) –

  • scoped_id (bool) –

  • vocab_term (bool) –

  • scoped_ref (Optional[int]) –

Return type:

str

add_namespaces(ns)
Parameters:

ns (Dict[str, str]) –

Return type:

None

add_schemas(ns, base_url)
Parameters:
  • ns (Union[List[str], str]) –

  • base_url (str) –

Return type:

None

add_context(newcontext)
Parameters:

newcontext (schema_salad.utils.ContextType) –

Return type:

None

resolve_ref(ref, base_url=None, checklinks=True, strict_foreign_properties=False, content_types=None)
Parameters:
  • ref (schema_salad.utils.ResolveType) –

  • base_url (Optional[str]) –

  • checklinks (bool) –

  • strict_foreign_properties (bool) –

  • content_types (Optional[List[str]]) –

Return type:

schema_salad.utils.ResolvedRefType

resolve_all(document, base_url, file_base=None, checklinks=True, strict_foreign_properties=False)
Parameters:
  • document (schema_salad.utils.ResolveType) –

  • base_url (str) –

  • file_base (Optional[str]) –

  • checklinks (bool) –

  • strict_foreign_properties (bool) –

Return type:

schema_salad.utils.ResolvedRefType

fetch(url, inject_ids=True, content_types=None)
Parameters:
  • url (str) –

  • inject_ids (bool) –

  • content_types (Optional[List[str]]) –

Return type:

schema_salad.utils.IdxResultType

validate_scoped(field, link, docid)
Parameters:
  • field (str) –

  • link (str) –

  • docid (str) –

Return type:

str

Parameters:
  • field (str) –

  • link (Union[str, ruamel.yaml.comments.CommentedSeq, ruamel.yaml.comments.CommentedMap]) –

  • docid (str) –

  • all_doc_ids (Dict[str, str]) –

Return type:

Union[str, ruamel.yaml.comments.CommentedSeq, ruamel.yaml.comments.CommentedMap]

getid(d)
Parameters:

d (Any) –

Return type:

Optional[str]

Parameters:
  • document (schema_salad.utils.ResolveType) –

  • base_url (str) –

  • all_doc_ids (Dict[str, str]) –

  • strict_foreign_properties (bool) –

Return type:

None