schema_salad.codegen

Generate language specific loaders for a particular SALAD schema.

Attributes

FIELD_SORT_ORDER

Exceptions

SchemaSaladException

Base class for all schema-salad exceptions.

Classes

CodeGenBase

Abstract base class for schema salad code generators.

CppCodeGen

Generation of C++ code for a given Schema Salad definition.

DlangCodeGen

Generation of D code for a given Schema Salad definition.

DotNetCodeGen

Generation of TypeScript code for a given Schema Salad definition.

JavaCodeGen

Abstract base class for schema salad code generators.

PythonCodeGen

Generation of Python code for a given Schema Salad definition.

Loader

TypeScriptCodeGen

Generation of TypeScript code for a given Schema Salad definition.

Functions

shortname(inputid)

Return the last segment of the provided fragment or path.

aslist(thing)

Wrap single items and lists.

codegen(lang, i, schema_metadata, loader[, target, ...])

Generate classes with loaders for the given Schema Salad description.

Module Contents

class schema_salad.codegen.CodeGenBase

Abstract base class for schema salad code generators.

declare_type(declared_type)

Add this type to our collection, if needed.

Parameters:

declared_type (TypeDef)

Return type:

TypeDef

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.

Parameters:
Return type:

None

abstract prologue()

Trigger to generate the prolouge code.

Return type:

None

static safe_name(name)
Abstractmethod:

Parameters:

name (str)

Return type:

str

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 (MutableSequence[str])

  • doc (str)

  • abstract (bool)

  • field_names (MutableSequence[str])

  • idfield (str)

  • optional_fields (Set[str])

Return type:

None

abstract end_class(classname, field_names)

Signal that we are done with this class.

Parameters:
  • classname (str)

  • field_names (List[str])

Return type:

None

abstract type_loader(type_declaration, container=None, no_link_check=None)

Parse the given type declaration and declare its components.

Parameters:
  • type_declaration (Union[List[Any], Dict[str, Any]])

  • container (Optional[str])

  • no_link_check (Optional[bool])

Return type:

TypeDef

abstract declare_field(name, fieldtype, doc, optional, subscope)

Output the code to load the given field.

Parameters:
Return type:

None

abstract declare_id_field(name, fieldtype, doc, optional)

Output the code to handle the given ID field.

Parameters:
Return type:

None

abstract uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check=None)

Construct the TypeDef for the given URI loader.

Parameters:
Return type:

TypeDef

abstract idmap_loader(field, inner, map_subject, map_predicate)

Construct the TypeDef for the given mapped ID loader.

Parameters:
Return type:

TypeDef

abstract typedsl_loader(inner, ref_scope)

Construct the TypeDef for the given DSL loader.

Parameters:
Return type:

TypeDef

abstract epilogue(root_loader)

Trigger to generate the epilouge code.

Parameters:

root_loader (TypeDef)

Return type:

None

abstract secondaryfilesdsl_loader(inner)

Construct the TypeDef for secondary files.

Parameters:

inner (TypeDef)

Return type:

TypeDef

class schema_salad.codegen.CppCodeGen(base, target, examples, package, copyright, spdx_copyright_text, spdx_license_identifier)

Bases: schema_salad.codegen_base.CodeGenBase

digraph inheritancea82e101643 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "CodeGenBase" [URL="../codegen_base/index.html#schema_salad.codegen_base.CodeGenBase",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="Abstract base class for schema salad code generators."]; "CppCodeGen" [URL="../cpp_codegen/index.html#schema_salad.cpp_codegen.CppCodeGen",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="Generation of C++ code for a given Schema Salad definition."]; "CodeGenBase" -> "CppCodeGen" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Generation of C++ code for a given Schema Salad definition.

Parameters:
  • base (str)

  • target (IO[str])

  • examples (Optional[str])

  • package (str)

  • copyright (Optional[str])

  • spdx_copyright_text (Optional[List[str]])

  • spdx_license_identifier (Optional[str])

convertTypeToCpp(type_declaration)

Convert a Schema Salad type to a C++ type.

Parameters:

type_declaration (Union[List[Any], Dict[str, Any], str])

Return type:

str

epilogue(root_loader)

Generate final part of our cpp file.

Parameters:

root_loader (Optional[schema_salad.codegen_base.TypeDef])

Return type:

None

parseRecordField(field)

Parse a record field.

Parameters:

field (Dict[str, Any])

Return type:

FieldDefinition

parseRecordSchema(stype)

Parse a record schema.

Parameters:

stype (Dict[str, Any])

Return type:

None

parseMapSchema(stype)

Parse a map schema.

Parameters:

stype (Dict[str, Any])

Return type:

str

parseUnionSchema(stype)

Parse a union schema.

Parameters:

stype (Dict[str, Any])

Return type:

str

parseEnum(stype)

Parse a schema salad enum.

Parameters:

stype (Dict[str, Any])

Return type:

str

parse(items)

Parse sechema salad items.

This function is being called from the outside and drives the whole code generation.

Parameters:

items (List[Dict[str, Any]])

Return type:

None

class schema_salad.codegen.DlangCodeGen(base, target, examples, package, copyright_, parser_info, salad_version)

Bases: schema_salad.codegen_base.CodeGenBase

digraph inheritanced5fbb77072 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "CodeGenBase" [URL="../codegen_base/index.html#schema_salad.codegen_base.CodeGenBase",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="Abstract base class for schema salad code generators."]; "DlangCodeGen" [URL="../dlang_codegen/index.html#schema_salad.dlang_codegen.DlangCodeGen",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="Generation of D code for a given Schema Salad definition."]; "CodeGenBase" -> "DlangCodeGen" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Generation of D code for a given Schema Salad definition.

Parameters:
  • base (str)

  • target (IO[str])

  • examples (Optional[str])

  • package (str)

  • copyright_ (Optional[str])

  • parser_info (Optional[str])

  • salad_version (str)

prologue()

Trigger to generate the prolouge code.

Return type:

None

epilogue(root_loader)

Trigger to generate the epilouge code.

Parameters:

root_loader (schema_salad.codegen_base.TypeDef)

Return type:

None

static safe_name(name)

Generate a safe version of the given name.

Parameters:

name (str)

Return type:

str

to_doc_comment(doc)

Return an embedded documentation comments for a given string.

Parameters:

doc (Union[None, str, List[str]])

Return type:

str

parse_record_field_type(type_, jsonld_pred)

Return an annotation string and a type string.

Parameters:
  • type_ (Any)

  • jsonld_pred (Union[None, str, Dict[str, Any]])

Return type:

Tuple[str, str]

parse_record_field(field, parent_name=None)

Return a declaration string for a given record field.

Parameters:
  • field (Dict[str, Any])

  • parent_name (Optional[str])

Return type:

str

parse_record_schema(stype)

Return a declaration string for a given record schema.

Parameters:

stype (Dict[str, Any])

Return type:

str

parse_enum(stype)

Return a declaration string for a given enum schema.

Parameters:

stype (Dict[str, Any])

Return type:

str

parse(items)

Generate D code from items and write it to target.

Parameters:

items (List[Dict[str, Any]])

Return type:

None

class schema_salad.codegen.DotNetCodeGen(base, examples, target, package)

Bases: schema_salad.codegen_base.CodeGenBase

digraph inheritance55c9f46b15 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "CodeGenBase" [URL="../codegen_base/index.html#schema_salad.codegen_base.CodeGenBase",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="Abstract base class for schema salad code generators."]; "DotNetCodeGen" [URL="../dotnet_codegen/index.html#schema_salad.dotnet_codegen.DotNetCodeGen",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="Generation of TypeScript code for a given Schema Salad definition."]; "CodeGenBase" -> "DotNetCodeGen" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Generation of TypeScript code for a given Schema Salad definition.

Parameters:
  • base (str)

  • examples (Optional[str])

  • target (Optional[str])

  • package (str)

prologue()

Trigger to generate the prolouge code.

Return type:

None

static safe_name(name)

Generate a safe version of the given name.

Parameters:

name (str)

Return type:

str

begin_class(classname, extends, doc, abstract, field_names, idfield, optional_fields)

Produce the header for the given class.

Parameters:
  • classname (str)

  • extends (MutableSequence[str])

  • doc (str)

  • abstract (bool)

  • field_names (MutableSequence[str])

  • idfield (str)

  • optional_fields (Set[str])

Return type:

None

end_class(classname, field_names)

Signal that we are done with this class.

Parameters:
  • classname (str)

  • field_names (List[str])

Return type:

None

type_loader(type_declaration, container=None, no_link_check=None)

Parse the given type declaration and declare its components.

Parameters:
  • type_declaration (Union[List[Any], Dict[str, Any], str])

  • container (Optional[str])

  • no_link_check (Optional[bool])

Return type:

schema_salad.codegen_base.TypeDef

type_loader_enum(type_declaration)
Parameters:

type_declaration (Dict[str, Any])

Return type:

schema_salad.codegen_base.TypeDef

declare_field(name, fieldtype, doc, optional, subscope)

Output the code to load the given field.

Parameters:
Return type:

None

declare_id_field(name, fieldtype, doc, optional)

Output the code to handle the given ID field.

Parameters:
Return type:

None

to_dotnet(val)

Convert a Python keyword to a DotNet keyword.

Parameters:

val (Any)

Return type:

Any

uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check=None)

Construct the TypeDef for the given URI loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

idmap_loader(field, inner, map_subject, map_predicate)

Construct the TypeDef for the given mapped ID loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

typedsl_loader(inner, ref_scope)

Construct the TypeDef for the given DSL loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

epilogue(root_loader)

Trigger to generate the epilouge code.

Parameters:

root_loader (schema_salad.codegen_base.TypeDef)

Return type:

None

secondaryfilesdsl_loader(inner)

Construct the TypeDef for secondary files.

Parameters:

inner (schema_salad.codegen_base.TypeDef)

Return type:

schema_salad.codegen_base.TypeDef

exception schema_salad.codegen.SchemaSaladException(msg, sl=None, children=None, bullet_for_children='')

Bases: Exception

digraph inheritance4003c1c300 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "SchemaSaladException" [URL="../exceptions/index.html#schema_salad.exceptions.SchemaSaladException",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="Base class for all schema-salad exceptions."]; }

Base class for all schema-salad exceptions.

Parameters:
propagate_sourceline()
Return type:

None

as_warning()
Return type:

SchemaSaladException

with_sourceline(sl)
Parameters:

sl (Optional[schema_salad.sourceline.SourceLine])

Return type:

SchemaSaladException

leaves()
Return type:

List[SchemaSaladException]

prefix()
Return type:

str

summary(level=0, with_bullet=False)
Parameters:
Return type:

str

__str__()

Convert to a string using pretty_str().

Return type:

str

pretty_str(level=0)
Parameters:

level (int)

Return type:

str

class schema_salad.codegen.JavaCodeGen(base, target, examples, package, copyright)

Bases: schema_salad.codegen_base.CodeGenBase

digraph inheritance7023753baa { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "CodeGenBase" [URL="../codegen_base/index.html#schema_salad.codegen_base.CodeGenBase",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="Abstract base class for schema salad code generators."]; "JavaCodeGen" [URL="../java_codegen/index.html#schema_salad.java_codegen.JavaCodeGen",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"]; "CodeGenBase" -> "JavaCodeGen" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Abstract base class for schema salad code generators.

Parameters:
  • base (str)

  • target (Optional[str])

  • examples (Optional[str])

  • package (str)

  • copyright (Optional[str])

prologue()

Trigger to generate the prolouge code.

Return type:

None

static property_name(name)
Parameters:

name (str)

Return type:

str

static safe_name(name)

Generate a safe version of the given name.

Parameters:

name (str)

Return type:

str

interface_name(n)
Parameters:

n (str)

Return type:

str

begin_class(classname, extends, doc, abstract, field_names, idfield, optional_fields)

Produce the header for the given class.

Parameters:
  • classname (str)

  • extends (MutableSequence[str])

  • doc (str)

  • abstract (bool)

  • field_names (MutableSequence[str])

  • idfield (str)

  • optional_fields (Set[str])

Return type:

None

end_class(classname, field_names)

Finish this class.

Parameters:
  • classname (str)

  • field_names (List[str])

Return type:

None

type_loader(type_declaration, container=None, no_link_check=None)

Parse the given type declaration and declare its components.

Parameters:
  • type_declaration (Union[List[Any], Dict[str, Any], str])

  • container (Optional[str])

  • no_link_check (Optional[bool])

Return type:

schema_salad.codegen_base.TypeDef

type_loader_enum(type_declaration)
Parameters:

type_declaration (Dict[str, Any])

Return type:

schema_salad.codegen_base.TypeDef

declare_field(name, fieldtype, doc, optional, subscope)

Output the code to load the given field.

Parameters:
Return type:

None

declare_id_field(name, fieldtype, doc, optional)

Output the code to handle the given ID field.

Parameters:
Return type:

None

uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check=None)

Construct the TypeDef for the given URI loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

idmap_loader(field, inner, map_subject, map_predicate)

Construct the TypeDef for the given mapped ID loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

typedsl_loader(inner, ref_scope)

Construct the TypeDef for the given DSL loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

to_java(val)
Parameters:

val (Any)

Return type:

Any

epilogue(root_loader)

Trigger to generate the epilouge code.

Parameters:

root_loader (schema_salad.codegen_base.TypeDef)

Return type:

None

secondaryfilesdsl_loader(inner)

Construct the TypeDef for secondary files.

Parameters:

inner (schema_salad.codegen_base.TypeDef)

Return type:

schema_salad.codegen_base.TypeDef

class schema_salad.codegen.PythonCodeGen(out, copyright, parser_info, salad_version)

Bases: schema_salad.codegen_base.CodeGenBase

digraph inheritanceaf3bbe197f { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "CodeGenBase" [URL="../codegen_base/index.html#schema_salad.codegen_base.CodeGenBase",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="Abstract base class for schema salad code generators."]; "PythonCodeGen" [URL="../python_codegen/index.html#schema_salad.python_codegen.PythonCodeGen",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="Generation of Python code for a given Schema Salad definition."]; "CodeGenBase" -> "PythonCodeGen" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Generation of Python code for a given Schema Salad definition.

Parameters:
  • out (IO[str])

  • copyright (Optional[str])

  • parser_info (str)

  • salad_version (str)

static safe_name(name)

Generate a safe version of the given name.

Parameters:

name (str)

Return type:

str

prologue()

Trigger to generate the prolouge code.

Return type:

None

begin_class(classname, extends, doc, abstract, field_names, idfield, optional_fields)

Produce the header for the given class.

Parameters:
  • classname (str)

  • extends (MutableSequence[str])

  • doc (str)

  • abstract (bool)

  • field_names (MutableSequence[str])

  • idfield (str)

  • optional_fields (Set[str])

Return type:

None

end_class(classname, field_names)

Signal that we are done with this class.

Parameters:
  • classname (str)

  • field_names (List[str])

Return type:

None

type_loader(type_declaration, container=None, no_link_check=None)

Parse the given type declaration and declare its components.

Parameters:
  • type_declaration (Union[List[Any], Dict[str, Any], str])

  • container (Optional[str])

  • no_link_check (Optional[bool])

Return type:

schema_salad.codegen_base.TypeDef

declare_id_field(name, fieldtype, doc, optional)

Output the code to handle the given ID field.

Parameters:
Return type:

None

declare_field(name, fieldtype, doc, optional, subscope)

Output the code to load the given field.

Parameters:
Return type:

None

uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check=None)

Construct the TypeDef for the given URI loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

idmap_loader(field, inner, map_subject, map_predicate)

Construct the TypeDef for the given mapped ID loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

typedsl_loader(inner, ref_scope)

Construct the TypeDef for the given DSL loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

secondaryfilesdsl_loader(inner)

Construct the TypeDef for secondary files.

Parameters:

inner (schema_salad.codegen_base.TypeDef)

Return type:

schema_salad.codegen_base.TypeDef

epilogue(root_loader)

Trigger to generate the epilouge code.

Parameters:

root_loader (schema_salad.codegen_base.TypeDef)

Return type:

None

class schema_salad.codegen.Loader(ctx, schemagraph=None, foreign_properties=None, idx=None, cache=None, session=None, fetcher_constructor=None, skip_schemas=None, url_fields=None, allow_attachments=None, doc_cache=True, salad_version=None)
Parameters:
  • ctx (schema_salad.utils.ContextType)

  • schemagraph (Optional[rdflib.graph.Graph])

  • foreign_properties (Optional[Set[str]])

  • idx (Optional[schema_salad.utils.IdxType])

  • cache (Optional[schema_salad.utils.CacheType])

  • session (Optional[requests.sessions.Session])

  • fetcher_constructor (Optional[schema_salad.utils.FetcherCallableType])

  • skip_schemas (Optional[bool])

  • url_fields (Optional[Set[str]])

  • allow_attachments (Optional[schema_salad.utils.AttachmentsType])

  • doc_cache (Union[str, bool])

  • salad_version (Optional[str])

expand_url(url, base_url, scoped_id=False, vocab_term=False, scoped_ref=None)
Parameters:
  • url (str)

  • base_url (str)

  • scoped_id (bool)

  • vocab_term (bool)

  • scoped_ref (Optional[int])

Return type:

str

add_namespaces(ns)
Parameters:

ns (Dict[str, str])

Return type:

None

add_schemas(ns, base_url)
Parameters:
Return type:

None

add_context(newcontext)
Parameters:

newcontext (schema_salad.utils.ContextType)

Return type:

None

resolve_ref(ref, base_url=None, checklinks=True, strict_foreign_properties=False, content_types=None)
Parameters:
  • ref (schema_salad.utils.ResolveType)

  • base_url (Optional[str])

  • checklinks (bool)

  • strict_foreign_properties (bool)

  • content_types (Optional[List[str]])

Return type:

schema_salad.utils.ResolvedRefType

resolve_all(document, base_url, file_base=None, checklinks=True, strict_foreign_properties=False)
Parameters:
  • document (schema_salad.utils.ResolveType)

  • base_url (str)

  • file_base (Optional[str])

  • checklinks (bool)

  • strict_foreign_properties (bool)

Return type:

schema_salad.utils.ResolvedRefType

fetch(url, inject_ids=True, content_types=None)
Parameters:
  • url (str)

  • inject_ids (bool)

  • content_types (Optional[List[str]])

Return type:

schema_salad.utils.IdxResultType

validate_scoped(field, link, docid)
Parameters:
Return type:

str

Parameters:
  • field (str)

  • link (Union[str, ruamel.yaml.comments.CommentedSeq, ruamel.yaml.comments.CommentedMap])

  • docid (str)

  • all_doc_ids (Dict[str, str])

Return type:

Union[str, ruamel.yaml.comments.CommentedSeq, ruamel.yaml.comments.CommentedMap]

getid(d)
Parameters:

d (Any)

Return type:

Optional[str]

Parameters:
  • document (schema_salad.utils.ResolveType)

  • base_url (str)

  • all_doc_ids (Dict[str, str])

  • strict_foreign_properties (bool)

Return type:

None

schema_salad.codegen.shortname(inputid)

Return the last segment of the provided fragment or path.

Parameters:

inputid (str)

Return type:

str

class schema_salad.codegen.TypeScriptCodeGen(base, examples, target, package)

Bases: schema_salad.codegen_base.CodeGenBase

digraph inheritancea95ed5de3b { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "CodeGenBase" [URL="../codegen_base/index.html#schema_salad.codegen_base.CodeGenBase",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="Abstract base class for schema salad code generators."]; "TypeScriptCodeGen" [URL="../typescript_codegen/index.html#schema_salad.typescript_codegen.TypeScriptCodeGen",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="Generation of TypeScript code for a given Schema Salad definition."]; "CodeGenBase" -> "TypeScriptCodeGen" [arrowsize=0.5,style="setlinewidth(0.5)"]; }

Generation of TypeScript code for a given Schema Salad definition.

Parameters:
  • base (str)

  • examples (Optional[str])

  • target (Optional[str])

  • package (str)

prologue()

Trigger to generate the prolouge code.

Return type:

None

static safe_name(name)

Generate a safe version of the given name.

Parameters:

name (str)

Return type:

str

begin_class(classname, extends, doc, abstract, field_names, idfield, optional_fields)

Produce the header for the given class.

Parameters:
  • classname (str)

  • extends (MutableSequence[str])

  • doc (str)

  • abstract (bool)

  • field_names (MutableSequence[str])

  • idfield (str)

  • optional_fields (Set[str])

Return type:

None

end_class(classname, field_names)

Signal that we are done with this class.

Parameters:
  • classname (str)

  • field_names (List[str])

Return type:

None

type_loader(type_declaration, container=None, no_link_check=None)

Parse the given type declaration and declare its components.

Parameters:
  • type_declaration (Union[List[Any], Dict[str, Any], str])

  • container (Optional[str])

  • no_link_check (Optional[bool])

Return type:

schema_salad.codegen_base.TypeDef

type_loader_enum(type_declaration)
Parameters:

type_declaration (Dict[str, Any])

Return type:

schema_salad.codegen_base.TypeDef

declare_field(name, fieldtype, doc, optional, subscope)

Output the code to load the given field.

Parameters:
Return type:

None

declare_id_field(name, fieldtype, doc, optional)

Output the code to handle the given ID field.

Parameters:
Return type:

None

to_typescript(val)

Convert a Python keyword to a TypeScript keyword.

Parameters:

val (Any)

Return type:

Any

uri_loader(inner, scoped_id, vocab_term, ref_scope, no_link_check=None)

Construct the TypeDef for the given URI loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

idmap_loader(field, inner, map_subject, map_predicate)

Construct the TypeDef for the given mapped ID loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

typedsl_loader(inner, ref_scope)

Construct the TypeDef for the given DSL loader.

Parameters:
Return type:

schema_salad.codegen_base.TypeDef

epilogue(root_loader)

Trigger to generate the epilouge code.

Parameters:

root_loader (schema_salad.codegen_base.TypeDef)

Return type:

None

secondaryfilesdsl_loader(inner)

Construct the TypeDef for secondary files.

Parameters:

inner (schema_salad.codegen_base.TypeDef)

Return type:

schema_salad.codegen_base.TypeDef

schema_salad.codegen.aslist(thing)

Wrap single items and lists.

Return lists unchanged.

Parameters:

thing (Any)

Return type:

MutableSequence[Any]

schema_salad.codegen.FIELD_SORT_ORDER = ['id', 'class', 'name']
schema_salad.codegen.codegen(lang, i, schema_metadata, loader, target=None, examples=None, package=None, copyright=None, spdx_copyright_text=None, spdx_license_identifier=None, parser_info=None)

Generate classes with loaders for the given Schema Salad description.

Parameters:
Return type:

None