finesse.script.adapter.ItemAdapter

Overview

class finesse.script.adapter.ItemAdapter(full_name, short_name=None, other_names=None, getter=None, factory=None, setter=None, documenter=None, singular=False, build_last=False)[source]

Bases: object

Adapter defining how a script instruction maps to/from a Python type.

This encapsulates the required information to take a script instruction and generate a corresponding Python object (e.g. a Laser from a laser l1 … instruction), to add it to a Model (or in the case of commands, set some model attribute), to dump that Python object back to script, and to generate documentation.

Parameters:
full_namestr

The instruction’s unabbreviated name. This must be alphanumeric and can contain underscores but no spaces.

short_namestr, optional

The instruction’s short form name, used when generating compact script. If not specified, full_name is used in cases where the short form is desired.

other_namessequence, optional

Any other supported names for this instruction.

getterItemDumper, optional

Object handling the retrieval of parameters from the Python object corresponding to this instruction.

factoryItemFactory, optional

Object handling the creation of the Python object corresponding to this instruction.

setterItemSetter, optional

Object handling the setting of parameters in the Python object corresponding to this instruction’s parameters.

documenterDocumenter

Object handling the retrieval of docstrings and syntax suggestions for the instruction.

singularbool, optional

Flag indicating that this instruction can be defined only once per script. Defaults to False.

build_lastbool, optional

Whether to build the Python object last, regardless of dependencies. This is useful for elements with implicit dependencies (see e.g. the cavity adapter). Be careful using this flag because statements for other adapters that depend on statements for adapters with this flag will be built first. Defaults to False.

Properties

ItemAdapter.aliases

The instruction alias(es).