schema_salad.python_codegen_support
===================================

.. py:module:: schema_salad.python_codegen_support

.. autoapi-nested-parse::

   Template code used by python_codegen.py.



Attributes
----------

.. autoapisummary::

   schema_salad.python_codegen_support.IdxType
   schema_salad.python_codegen_support.save_type


Classes
-------

.. autoapisummary::

   schema_salad.python_codegen_support.LoadingOptions
   schema_salad.python_codegen_support.Saveable


Functions
---------

.. autoapisummary::

   schema_salad.python_codegen_support.load_field
   schema_salad.python_codegen_support.extract_type
   schema_salad.python_codegen_support.convert_typing
   schema_salad.python_codegen_support.parse_errors
   schema_salad.python_codegen_support.save
   schema_salad.python_codegen_support.save_with_metadata
   schema_salad.python_codegen_support.expand_url
   schema_salad.python_codegen_support.file_uri
   schema_salad.python_codegen_support.prefix_url
   schema_salad.python_codegen_support.save_relative_uri
   schema_salad.python_codegen_support.shortname


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

.. py:data:: IdxType

.. py:class:: LoadingOptions(fetcher = None, namespaces = None, schemas = None, fileuri = None, copyfrom = None, original_doc = None, addl_metadata = None, baseuri = None, idx = None, imports = None, includes = None, no_link_check = None, container = None)

   .. py:attribute:: idx
      :type:  IdxType


   .. py:attribute:: fileuri
      :type:  Optional[str]


   .. py:attribute:: baseuri
      :type:  str


   .. py:attribute:: namespaces
      :type:  collections.abc.MutableMapping[str, str]


   .. py:attribute:: schemas
      :type:  collections.abc.MutableSequence[str]


   .. py:attribute:: original_doc
      :type:  Optional[Any]


   .. py:attribute:: addl_metadata
      :type:  collections.abc.MutableMapping[str, Any]


   .. py:attribute:: fetcher
      :type:  schema_salad.fetcher.Fetcher


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


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


   .. py:attribute:: cache
      :type:  schema_salad.utils.CacheType


   .. py:attribute:: imports
      :type:  list[str]


   .. py:attribute:: includes
      :type:  list[str]


   .. py:attribute:: no_link_check
      :type:  Optional[bool]


   .. py:attribute:: container
      :type:  Optional[str]


   .. py:property:: graph
      :type: rdflib.Graph


      Generate a merged rdflib.Graph from all entries in self.schemas.



.. py:class:: Saveable

   Bases: :py:obj:`abc.ABC`

   .. autoapi-inheritance-diagram:: schema_salad.python_codegen_support.Saveable
      :parts: 1


   Mark classes than have a save() and fromDoc() function.


   .. py:method:: fromDoc(_doc, baseuri, loadingOptions, docRoot = None)
      :classmethod:

      :abstractmethod:


      Construct this object from the result of yaml.load().



   .. py:method:: save(top = False, base_url = '', relative_uris = True)
      :abstractmethod:


      Convert this object to a JSON/YAML friendly dictionary.



.. py:function:: load_field(val, fieldtype, baseuri, loadingOptions, lc = None)

   Load field.


.. py:data:: save_type

.. py:function:: extract_type(val_type)

   Take a type of value, and extracts the value as a string.


.. py:function:: convert_typing(val_type)

   Normalize type names to schema-salad types.


.. py:function:: parse_errors(error_message)

   Parse error messages from several loaders into one error message.


.. py:function:: save(val, top = True, base_url = '', relative_uris = True)

.. py:function:: save_with_metadata(val, valLoadingOpts, top = True, base_url = '', relative_uris = True)

   Save and set $namespaces, $schemas, $base and any other metadata fields at the top level.


.. py:function:: expand_url(url, base_url, loadingOptions, scoped_id = False, vocab_term = False, scoped_ref = None)

.. py:function:: file_uri(path, split_frag = False)

   Transform a file path into a URL with file scheme.


.. py:function:: prefix_url(url, namespaces)

   Expand short forms into full URLs using the given namespace dictionary.


.. py:function:: save_relative_uri(uri, base_url, scoped_id, ref_scope, relative_uris)

   Convert any URI to a relative one, obeying the scoping rules.


.. py:function:: shortname(inputid)

   Compute the shortname of a fully qualified identifier.

   See https://w3id.org/cwl/v1.2/SchemaSalad.html#Short_names.


