schema_salad.ref_resolver

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)

Module Contents

schema_salad.ref_resolver.file_uri(path, split_frag=False)
Parameters:
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, ruamel.yaml.comments.CommentedMap | ruamel.yaml.comments.CommentedSeq | str | None]

Inheritance diagram of schema_salad.ref_resolver.NormDict

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

Parameters:

normalize (collections.abc.Callable[[str], str])

normalize: Final
__eq__(other)

Return self==value.

Parameters:

other (Any)

Return type:

bool

__getitem__(key)

Return self[key].

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 (rdflib.graph.Graph | None)

  • foreign_properties (set[str] | None)

  • idx (schema_salad.utils.IdxType | None)

  • cache (schema_salad.utils.CacheType | None)

  • session (requests.sessions.Session | None)

  • fetcher_constructor (schema_salad.utils.FetcherCallableType | None)

  • skip_schemas (bool | None)

  • url_fields (set[str] | None)

  • allow_attachments (schema_salad.utils.AttachmentsType | None)

  • doc_cache (str | bool)

  • salad_version (str | None)

idx: schema_salad.utils.IdxType
ctx: Final[schema_salad.utils.ContextType]
graph
foreign_properties: Final
cache: Final
skip_schemas: Final
session
fetcher_constructor: Final
fetcher: Final
fetch_text: Final
check_exists: Final
url_fields: Final[set[str]]
scoped_ref_fields: Final[dict[str, int]]
vocab_fields: Final[set[str]]
identifiers: Final[list[str]] = []
standalone: set[str] | None = None
nolinkcheck: Final[set[str]]
vocab: Final[dict[str, str]]
rvocab: Final[dict[str, str]]
idmap: Final[dict[str, str]]
mapPredicate: Final[dict[str, str]]
type_dsl_fields: Final[set[str]]
subscopes: Final[dict[str, str]]
secondaryFile_dsl_fields: Final[set[str]]
allow_attachments: Final = None
salad_version: Final
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 (int | None)

Return type:

str

add_namespaces(ns)

Add the given namespace to our vocab list.

Parameters:

ns (dict[str, str])

Return type:

None

add_schemas(ns, base_url)

Fetch external schemas and add them to the graph.

Parameters:
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 (str | None)

  • checklinks (bool)

  • strict_foreign_properties (bool)

  • content_types (list[str] | None)

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 (str | None)

  • checklinks (bool)

  • strict_foreign_properties (bool)

Return type:

schema_salad.utils.ResolvedRefType

fetch(url, inject_ids=True, content_types=None)
Parameters:
Return type:

schema_salad.utils.IdxResultType

validate_scoped(field, link, docid)
Parameters:
Return type:

str

Parameters:
  • field (str)

  • link (str | ruamel.yaml.comments.CommentedSeq | ruamel.yaml.comments.CommentedMap)

  • docid (str)

  • all_doc_ids (dict[str, str])

Return type:

str | ruamel.yaml.comments.CommentedSeq | ruamel.yaml.comments.CommentedMap

getid(d)

Use our identifiers to extract the first match from the document.

Parameters:

d (Any)

Return type:

str | None

Parameters:
  • document (schema_salad.utils.ResolveType)

  • base_url (str)

  • all_doc_ids (dict[str, str])

  • strict_foreign_properties (bool)

Return type:

None