schema_salad.codegen_base
Base class for the generation of loaders from schema-salad definitions.
Classes
Schema Salad type description. |
|
Lazy initialization logic. |
|
Abstract base class for schema salad code generators. |
Module Contents
- class schema_salad.codegen_base.TypeDef(name, init, is_uri=False, scoped_id=False, ref_scope=0, loader_type=None, instance_type=None, abstract=False)
Schema Salad type description.
- Parameters:
- __slots__ = ['name', 'init', 'is_uri', 'scoped_id', 'ref_scope', 'loader_type', 'instance_type', 'abstract']
- name
- init
- is_uri
- scoped_id
- ref_scope
- abstract
- loader_type
- instance_type
- class schema_salad.codegen_base.LazyInitDef(name, init)
Lazy initialization logic.
- __slots__ = ('name', 'init')
- name
- init
- class schema_salad.codegen_base.CodeGenBase
Abstract base class for schema salad code generators.
- collected_types: collections.OrderedDict[str, TypeDef]
- lazy_inits: collections.OrderedDict[str, LazyInitDef]
- declare_type(declared_type)
Add this type to our collection, if needed.
- add_lazy_init(lazy_init)
Add lazy initialization logic for a given type.
- Parameters:
lazy_init (LazyInitDef)
- Return type:
None
- add_vocab(name, uri)
Add the given name as an abbreviation for the given URI.
- abstract prologue()
Trigger to generate the prolouge code.
- Return type:
None
- static safe_name(name)
-
Generate a safe version of the given name.
- abstract begin_class(classname, extends, doc, abstract, field_names, idfield, optional_fields)
Produce the header for the given class.
- Parameters:
classname (str)
extends (collections.abc.MutableSequence[str])
doc (str)
abstract (bool)
field_names (collections.abc.MutableSequence[str])
idfield (str)
- Return type:
None
- abstract end_class(classname, field_names)
Signal that we are done with this class.
- abstract type_loader(type_declaration, container=None, no_link_check=None)
Parse the given type declaration and declare its components.
- abstract declare_field(name, fieldtype, doc, optional, subscope)
Output the code to load the given field.
- abstract declare_id_field(name, fieldtype, doc, optional)
Output the code to handle the given ID field.
- abstract uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check=None)
Construct the TypeDef for the given URI loader.
- abstract idmap_loader(field, inner, map_subject, map_predicate)
Construct the TypeDef for the given mapped ID loader.
- abstract typedsl_loader(inner, ref_scope)
Construct the TypeDef for the given DSL loader.