schema_salad.codegen_base
=========================

.. py:module:: schema_salad.codegen_base

.. autoapi-nested-parse::

   Base class for the generation of loaders from schema-salad definitions.



Classes
-------

.. autoapisummary::

   schema_salad.codegen_base.TypeDef
   schema_salad.codegen_base.LazyInitDef
   schema_salad.codegen_base.CodeGenBase


Module Contents
---------------

.. py:class:: TypeDef(name, init, is_uri = False, scoped_id = False, ref_scope = 0, loader_type = None, instance_type = None, abstract = False)

   Schema Salad type description.


   .. py:attribute:: __slots__
      :value: ['name', 'init', 'is_uri', 'scoped_id', 'ref_scope', 'loader_type', 'instance_type', 'abstract']



   .. py:attribute:: name


   .. py:attribute:: init


   .. py:attribute:: is_uri


   .. py:attribute:: scoped_id


   .. py:attribute:: ref_scope


   .. py:attribute:: abstract


   .. py:attribute:: loader_type


   .. py:attribute:: instance_type


.. py:class:: LazyInitDef(name, init)

   Lazy initialization logic.


   .. py:attribute:: __slots__
      :value: ('name', 'init')



   .. py:attribute:: name


   .. py:attribute:: init


.. py:class:: CodeGenBase

   Abstract base class for schema salad code generators.


   .. py:attribute:: collected_types
      :type:  collections.OrderedDict[str, TypeDef]


   .. py:attribute:: lazy_inits
      :type:  collections.OrderedDict[str, LazyInitDef]


   .. py:attribute:: vocab
      :type:  dict[str, str]


   .. py:method:: declare_type(declared_type)

      Add this type to our collection, if needed.



   .. py:method:: add_lazy_init(lazy_init)

      Add lazy initialization logic for a given type.



   .. py:method:: add_vocab(name, uri)

      Add the given name as an abbreviation for the given URI.



   .. py:method:: prologue()
      :abstractmethod:


      Trigger to generate the prolouge code.



   .. py:method:: safe_name(name)
      :staticmethod:

      :abstractmethod:


      Generate a safe version of the given name.



   .. py:method:: begin_class(classname, extends, doc, abstract, field_names, idfield, optional_fields)
      :abstractmethod:


      Produce the header for the given class.



   .. py:method:: end_class(classname, field_names)
      :abstractmethod:


      Signal that we are done with this class.



   .. py:method:: type_loader(type_declaration, container = None, no_link_check = None)
      :abstractmethod:


      Parse the given type declaration and declare its components.



   .. py:method:: declare_field(name, fieldtype, doc, optional, subscope)
      :abstractmethod:


      Output the code to load the given field.



   .. py:method:: declare_id_field(name, fieldtype, doc, optional)
      :abstractmethod:


      Output the code to handle the given ID field.



   .. py:method:: uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check = None)
      :abstractmethod:


      Construct the TypeDef for the given URI loader.



   .. py:method:: idmap_loader(field, inner, map_subject, map_predicate)
      :abstractmethod:


      Construct the TypeDef for the given mapped ID loader.



   .. py:method:: typedsl_loader(inner, ref_scope)
      :abstractmethod:


      Construct the TypeDef for the given DSL loader.



   .. py:method:: epilogue(root_loader)
      :abstractmethod:


      Trigger to generate the epilouge code.



   .. py:method:: secondaryfilesdsl_loader(inner)
      :abstractmethod:


      Construct the TypeDef for secondary files.



