OpenQuizz
Une application de gestion des contenus pédagogiques
jsonschema._utils Namespace Reference

Data Structures

class  Unset
 
class  URIDict
 

Functions

def load_schema (name)
 
def indent (string, times=1)
 
def format_as_index (indices)
 
def find_additional_properties (instance, schema)
 
def extras_msg (extras)
 
def types_msg (instance, types)
 
def flatten (suitable_for_isinstance)
 
def ensure_list (thing)
 
def equal (one, two)
 
def unbool (element, true=object(), false=object())
 
def uniq (container)
 

Function Documentation

◆ ensure_list()

def jsonschema._utils.ensure_list (   thing)
Wrap ``thing`` in a list if it's a single str.

Otherwise, return it unchanged.

◆ equal()

def jsonschema._utils.equal (   one,
  two 
)
Check if two things are equal, but evade booleans and ints being equal.

◆ extras_msg()

def jsonschema._utils.extras_msg (   extras)
Create an error message for extra items or properties.

◆ find_additional_properties()

def jsonschema._utils.find_additional_properties (   instance,
  schema 
)
Return the set of additional properties for the given ``instance``.

Weeds out properties that should have been validated by ``properties`` and
/ or ``patternProperties``.

Assumes ``instance`` is dict-like already.

◆ flatten()

def jsonschema._utils.flatten (   suitable_for_isinstance)
isinstance() can accept a bunch of really annoying different types:
    * a single type
    * a tuple of types
    * an arbitrary nested tree of tuples

Return a flattened tuple of the given argument.

◆ format_as_index()

def jsonschema._utils.format_as_index (   indices)
Construct a single string containing indexing operations for the indices.

For example, [1, 2, "foo"] -> [1][2]["foo"]

Arguments:

    indices (sequence):

        The indices to format.

◆ indent()

def jsonschema._utils.indent (   string,
  times = 1 
)
A dumb version of `textwrap.indent` from Python 3.3.

◆ load_schema()

def jsonschema._utils.load_schema (   name)
Load a schema from ./schemas/``name``.json and return it.

◆ types_msg()

def jsonschema._utils.types_msg (   instance,
  types 
)
Create an error message for a failure to match the given types.

If the ``instance`` is an object and contains a ``name`` property, it will
be considered to be a description of that object and used as its type.

Otherwise the message is simply the reprs of the given ``types``.

◆ unbool()

def jsonschema._utils.unbool (   element,
  true = object(),
  false = object() 
)
A hack to make True and 1 and False and 0 unique for ``uniq``.

◆ uniq()

def jsonschema._utils.uniq (   container)
Check if all of a container's elements are unique.

Successively tries first to rely that the elements are hashable, then
falls back on them being sortable, and finally falls back on brute
force.