schema_salad.python_codegen
Python code generator for a given schema salad definition.
Module Contents
Classes
Generation of Python code for a given Schema Salad definition. |
Functions
|
Use black to format this snippet. |
Attributes
- schema_salad.python_codegen.black
- schema_salad.python_codegen.prims
- schema_salad.python_codegen.fmt(text, indent)
Use black to format this snippet.
:param indent the indent level for the current context
- class schema_salad.python_codegen.PythonCodeGen(out, copyright, parser_info, salad_version)
Bases:
digraph inheritancefbba5b07c9 { 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="#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)"]; }schema_salad.codegen_base.CodeGenBase
Generation of Python code for a given Schema Salad definition.
- static safe_name(name)
Generate a safe version of the given name.
- 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.
- end_class(classname, field_names)
Signal that we are done with this class.
- type_loader(type_declaration)
Parse the given type declaration and declare its components.
- Parameters:
- Return type:
- declare_id_field(name, fieldtype, doc, optional)
Output the code to handle the given ID field.
- Parameters:
name (str) –
fieldtype (schema_salad.codegen_base.TypeDef) –
doc (str) –
optional (bool) –
- Return type:
None
- declare_field(name, fieldtype, doc, optional, subscope)
Output the code to load the given field.
- Parameters:
name (str) –
fieldtype (schema_salad.codegen_base.TypeDef) –
doc (Optional[str]) –
optional (bool) –
subscope (str) –
- Return type:
None
- uri_loader(inner, scoped_id, vocab_term, ref_scope)
Construct the TypeDef for the given URI loader.
- Parameters:
inner (schema_salad.codegen_base.TypeDef) –
scoped_id (bool) –
vocab_term (bool) –
ref_scope (Optional[int]) –
- Return type:
- idmap_loader(field, inner, map_subject, map_predicate)
Construct the TypeDef for the given mapped ID loader.
- Parameters:
field (str) –
inner (schema_salad.codegen_base.TypeDef) –
map_subject (str) –
map_predicate (Optional[str]) –
- Return type:
- typedsl_loader(inner, ref_scope)
Construct the TypeDef for the given DSL loader.
- Parameters:
inner (schema_salad.codegen_base.TypeDef) –
ref_scope (Optional[int]) –
- Return type:
- secondaryfilesdsl_loader(inner)
Construct the TypeDef for secondary files.
- Parameters:
inner (schema_salad.codegen_base.TypeDef) –
- Return type:
- epilogue(root_loader)
Trigger to generate the epilouge code.
- Parameters:
root_loader (schema_salad.codegen_base.TypeDef) –
- Return type:
None