API Reference¶
Unlike most other ZOTI tools the API of ZOTI-Gen is not particularly interesting, since it is meant to be used mainly as a CLI tool. More important, though, is its exported core representation used when creating Template Libraries, documented in its respective page.
The Project Handler¶
- class zoti_gen.builder.Builder(main: str, srcs: List[zoti_yaml.handlers.Module], annotation=(None, None))[source]¶
This handler takes care of loading input specifications, templates, building and dumping target code artifacts.
- Parameters:
main – the qualified name of the main module (containing a
top
entry in preamble which points to the project’s top block)srcs – a list of initialized zoti_yaml.Module containing all the raw input specifications. Used for their qualified name queries.
annotations – formatted string for printing
Block
information (before, after) the template expansion. In the formatting, the variablecomp
represents the currentBlock
object.
- main: zoti_gen.core.Ref¶
Constructed path to the top (i.e., main) block
- requs: zoti_gen.core.Requirement¶
Resolved dependencies. Available only after calling
resolve()
.
- get(ref=None, caller=None) zoti_gen.core.Block [source]¶
Gets a
Block
object using its qualified name. If the the block has been parsed before it returns the previously-constructed block, otherwise it follows the decision flow:it searches the specificationsif it refers to a library template| it imports the base constructor using importlibelse| usesBlock
base constructorparses the specifications and constructs the block
The Core Representation¶
All core types are re-exported by zoti_gen
and are meant to be used
when defining template components.
- class zoti_gen.core.Block(name: str, prototype: zoti_gen.core.Template =, requirement: typing.Optional[zoti_gen.core.Requirement] = None, label: collections.OrderedDict[str, zoti_gen.core.Label] = <factory>, param: typing.Dict = <factory>, code: typing.Optional[str] = None, instance: typing.List[zoti_gen.core.Instance] = <factory>, _info: typing.Dict = <factory>)[source]¶
Base class for block structure.
- name: str¶
Unique ID of block.
- prototype: zoti_gen.core.Template¶
Target dependent function signature provided by the type system
- requirement: Optional[zoti_gen.core.Requirement] = None¶
Block prerequisites.
- label: collections.OrderedDict[str, zoti_gen.core.Label]¶
Ordered dictionary of labels
- param: Dict¶
Generic parameters
- code: Optional[str] = None¶
Target code for block, either as Jinja template or as raw text
- instance: List[zoti_gen.core.Instance]¶
list of instances that bind template (code) placeholders to other blocks
- class zoti_gen.core.Requirement(requirement, **kwargs)[source]¶
Illustrates prerquisites. Stores input iterables (e.g., lists) as dependency graphs.
- Parameters:
requirement – dictionary of iterables.
- requirement: Dict[str, networkx.classes.digraph.DiGraph]¶
Dictionary of dependency graphs.
- update(other: Optional[zoti_gen.core.Requirement])[source]¶
merges two
Requirement
entries updating the dependency graphs.
- class zoti_gen.core.Label(name: str, usage: zoti_gen.core.Template, glue: typing.Dict, _info: typing.Dict = <factory>)[source]¶
Carries information about labels (filled in by type system)
- name: str¶
Unique name in the scope of a block
- usage: zoti_gen.core.Template¶
Default usage template. Called on top-level (non-binding) instances.
- glue: Dict¶
Dictionary of templates passed from the type system.
- class zoti_gen.core.Instance(placeholder: typing.Optional[str], block: typing.Optional[typing.Dict], directive: typing.List[str], bind: typing.List[zoti_gen.core.Bind], usage: zoti_gen.core.Template, _info: typing.Dict = <factory>)[source]¶
Entry binding a placeholder in the parent’s template code to another block.
- placeholder: Optional[str]¶
ID for the template placeholder
- block: Optional[Dict]¶
ID of the block referenced to fill the placeholder
- bind: List[zoti_gen.core.Bind]¶
list of bindings between the parent block and referenced block
- usage: zoti_gen.core.Template¶
Target-dependent template passed by type system
- class zoti_gen.core.Bind(func: str, args: typing.Dict, _info: typing.Dict = <factory>)[source]¶
Deserialized version of a binding, containing directily bind resolver arguments.
- func: str¶
name of the binding function (see schema entries)
- args: Dict¶
arguments passed to the binding function