OpenQuizz
Une application de gestion des contenus pédagogiques
RefResolver Class Reference
Inheritance diagram for RefResolver:
Collaboration diagram for RefResolver:

Public Member Functions

def __init__ (self, base_uri, referrer, store=(), cache_remote=True, handlers=(), urljoin_cache=None, remote_cache=None)
 
def from_schema (cls, schema, id_of=_id_of, *args, **kwargs)
 
def push_scope (self, scope)
 
def pop_scope (self)
 
def resolution_scope (self)
 
def base_uri (self)
 
def in_scope (self, scope)
 
def resolving (self, ref)
 
def resolve (self, ref)
 
def resolve_from_url (self, url)
 
def resolve_fragment (self, document, fragment)
 
def resolve_remote (self, uri)
 

Data Fields

 referrer
 
 cache_remote
 
 handlers
 
 store
 

Detailed Description

Resolve JSON References.

Arguments:

    base_uri (str):

        The URI of the referring document

    referrer:

        The actual referring document

    store (dict):

        A mapping from URIs to documents to cache

    cache_remote (bool):

        Whether remote refs should be cached after first resolution

    handlers (dict):

        A mapping from URI schemes to functions that should be used
        to retrieve them

    urljoin_cache (:func:`functools.lru_cache`):

        A cache that will be used for caching the results of joining
        the resolution scope to subscopes.

    remote_cache (:func:`functools.lru_cache`):

        A cache that will be used for caching the results of
        resolved remote URLs.

Attributes:

    cache_remote (bool):

        Whether remote refs should be cached after first resolution

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  base_uri,
  referrer,
  store = (),
  cache_remote = True,
  handlers = (),
  urljoin_cache = None,
  remote_cache = None 
)

Member Function Documentation

◆ base_uri()

def base_uri (   self)
Retrieve the current base URI, not including any fragment.

◆ from_schema()

def from_schema (   cls,
  schema,
  id_of = _id_of,
args,
**  kwargs 
)
Construct a resolver from a JSON schema object.

Arguments:

    schema:

the referring schema

Returns:

    `RefResolver`

◆ in_scope()

def in_scope (   self,
  scope 
)
Temporarily enter the given scope for the duration of the context.

◆ pop_scope()

def pop_scope (   self)
Exit the most recent entered scope.

Treats further dereferences as being performed underneath the
original scope.

Don't call this method more times than `push_scope` has been
called.

◆ push_scope()

def push_scope (   self,
  scope 
)
Enter a given sub-scope.

Treats further dereferences as being performed underneath the
given scope.

◆ resolution_scope()

def resolution_scope (   self)
Retrieve the current resolution scope.

◆ resolve()

def resolve (   self,
  ref 
)
Resolve the given reference.

◆ resolve_fragment()

def resolve_fragment (   self,
  document,
  fragment 
)
Resolve a ``fragment`` within the referenced ``document``.

Arguments:

    document:

The referent document

    fragment (str):

a URI fragment to resolve within it

◆ resolve_from_url()

def resolve_from_url (   self,
  url 
)
Resolve the given remote URL.

◆ resolve_remote()

def resolve_remote (   self,
  uri 
)
Resolve a remote ``uri``.

If called directly, does not check the store first, but after
retrieving the document at the specified URI it will be saved in
the store if :attr:`cache_remote` is True.

.. note::

    If the requests_ library is present, ``jsonschema`` will use it to
    request the remote ``uri``, so that the correct encoding is
    detected and used.

    If it isn't, or if the scheme of the ``uri`` is not ``http`` or
    ``https``, UTF-8 is assumed.

Arguments:

    uri (str):

The URI to resolve

Returns:

    The retrieved document

.. _requests: https://pypi.org/project/requests/

◆ resolving()

def resolving (   self,
  ref 
)
Resolve the given ``ref`` and enter its resolution scope.

Exits the scope on exit of this context manager.

Arguments:

    ref (str):

The reference to resolve

Field Documentation

◆ cache_remote

cache_remote

◆ handlers

handlers

◆ referrer

referrer

◆ store

store

The documentation for this class was generated from the following file: