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
Bases:
digraph inheritanceb626017074 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "NamedTuple" [URL="https://docs.python.org/3/library/typing.html#typing.NamedTuple",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "TypeDef" [URL="#schema_salad.codegen_base.TypeDef",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Schema Salad type description."]; "NamedTuple" -> "TypeDef" [arrowsize=0.5,style="setlinewidth(0.5)"]; }NamedTupleSchema Salad type description.
- class schema_salad.codegen_base.LazyInitDef
Bases:
digraph inheritance94fd1b3ab5 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "LazyInitDef" [URL="#schema_salad.codegen_base.LazyInitDef",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Lazy initialization logic."]; "NamedTuple" -> "LazyInitDef" [arrowsize=0.5,style="setlinewidth(0.5)"]; "NamedTuple" [URL="https://docs.python.org/3/library/typing.html#typing.NamedTuple",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; }NamedTupleLazy initialization logic.
- 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.
- abstractmethod prologue()
Trigger to generate the prolouge code.
- Return type:
None
- static safe_name(name)
-
Generate a safe version of the given name.
- abstractmethod 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
- abstractmethod end_class(classname, field_names)
Signal that we are done with this class.
- abstractmethod type_loader(type_declaration, container=None, no_link_check=None)
Parse the given type declaration and declare its components.
- abstractmethod declare_field(name, fieldtype, doc, optional, subscope)
Output the code to load the given field.
- abstractmethod declare_id_field(name, fieldtype, doc, optional)
Output the code to handle the given ID field.
- abstractmethod uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check=None)
Construct the TypeDef for the given URI loader.
- abstractmethod idmap_loader(field, inner, map_subject, map_predicate)
Construct the TypeDef for the given mapped ID loader.
- abstractmethod typedsl_loader(inner, ref_scope)
Construct the TypeDef for the given DSL loader.