gemseo / third_party / fastjsonschema

generator module

class gemseo.third_party.fastjsonschema.generator.CodeGenerator(definition, resolver=None)[source]

Bases: object

This class is not supposed to be used directly. Anything inside of this class can be changed without noticing.

This class generates code of validation function from JSON schema object as string. Example:

CodeGenerator(json_schema_definition).func_code
INDENT = 4
create_variable_is_dict()[source]

Append code for creating variable with bool if it’s instance of list with a name {variable}_is_dict. Similar to create_variable_with_length.

create_variable_is_list()[source]

Append code for creating variable with bool if it’s instance of list with a name {variable}_is_list. Similar to create_variable_with_length.

create_variable_keys()[source]

Append code for creating variable with keys of that variable (dictionary) with a name {variable}_keys. Similar to create_variable_with_length.

create_variable_with_length()[source]

Append code for creating variable with length of that variable (for example length of list or dictionary) with name {variable}_len. It can be called several times and always it’s done only when that variable still does not exists.

property func_code

Returns generated code of whole validation function as string.

generate_func_code()[source]

Creates base code of validation function and calls helper for creating code by definition.

generate_func_code_block(definition, variable, variable_name, clear_variables=False)[source]

Creates validation rules for current definition.

generate_ref()[source]

Ref can be link to remote or local definition.

{'$ref': 'http://json-schema.org/draft-04/schema#'}
{
    'properties': {
        'foo': {'type': 'integer'},
        'bar': {'$ref': '#/properties/foo'}
    }
}
generate_validation_function(uri, name)[source]

Generate validation function for given uri with given name

property global_state

Returns global variables for generating function from func_code. Includes compiled regular expressions and imports, so it does not have to do it every time when validation function is called.

property global_state_code

Returns global variables for generating function from func_code as code. Includes compiled regular expressions and imports.

l(*args, **kwds)
run_generate_functions(definition)[source]
gemseo.third_party.fastjsonschema.generator.enforce_list(variable)[source]