Schema#

Methods for interacting with or reasoning about JSON Schema and CSV codelists.

jscc.schema.is_codelist(fieldnames)[source]#
Parameters:

fieldnames (list) – the fieldnames of the CSV

Returns:

whether the CSV is a codelist

Return type:

bool

jscc.schema.is_json_schema(data)[source]#
Parameters:

data (dict) – JSON data

Returns:

whether the JSON data is a JSON Schema

Return type:

bool

jscc.schema.is_json_merge_patch(data)[source]#
Parameters:

data (dict) – JSON data

Returns:

whether the JSON data is a JSON Merge Patch

Return type:

bool

jscc.schema.is_array_of_objects(field)[source]#
Parameters:

field (dict) – the field

Returns:

whether a field is an array of objects

Return type:

bool

jscc.schema.is_missing_property(field, prop)[source]#
Parameters:
  • field (dict) – the field

  • prop (str) – the property

Returns:

whether a field’s property isn’t set, is empty, or is whitespace

Return type:

bool

jscc.schema.get_types(field)[source]#

Returns a field’s “type” as a list.

Parameters:

field (dict) – the field

Returns:

a field’s “type”

Return type:

list

jscc.schema.extend_schema(basename, schema, metadata, codelists=None)[source]#

Patches a JSON Schema with an extension’s dependencies, recursively.

If codelists is provided, it will be updated with the codelists from the dependencies.

Parameters:
  • basename (str) – the JSON Schema file’s basename

  • schema (dict) – the JSON Schema file’s parsed contents

  • metadata (dict) – the extension metadata file’s parsed contents

  • codelists (set) – any set

Returns:

the patched schema

Return type:

dict

class jscc.schema.RejectingDict(dict=None, /, **kwargs)[source]#

A dict that raises an error if a key is set more than once.

jscc.schema.rejecting_dict(pairs)[source]#

An object_pairs_hook method that allows a key to be set at most once.