8.5.1.2. pymodaq_utils.plugin_tools.contract module

The contract of an instrument plugin: the methods a plugin class has to (or should) override.

This is the single place where these lists are defined. The static rules (pymodaq_utils.plugin_tools.rules), the checks (pymodaq_utils.plugin_tools.checks), the plugin tests and the documentation read them from here, so they cannot disagree.

Added in version 5.3.5.

class pymodaq_utils.plugin_tools.contract.PluginMethod(name, kind, mandatory, purpose, returns='', legacy_name='')[source]

Bases: object

One method of an actuator or detector plugin

Parameters:
  • name (str) – name of the method in the plugin class

  • kind (Literal['move', 'viewer']) – actuator (DAQ_Move_base) or detector (DAQ_Viewer_base)

  • mandatory (bool) – if True, a plugin that does not override it is wrong (error). Otherwise the base class has a default that does nothing or raises NotImplementedError: override it when the instrument can do it.

  • purpose (str) – when it is called and what it has to do

  • returns (str) – what it has to return (’’ if nothing)

  • legacy_name (str) – deprecated name that PyMoDAQ still calls if the method is not defined (’’ if none): a plugin defining it fulfils the contract (with a deprecation warning, see rule PMQ312)

kind: Literal['move', 'viewer']
legacy_name: str = ''
mandatory: bool
name: str
purpose: str
returns: str = ''
pymodaq_utils.plugin_tools.contract.contract_as_rst()[source]

The contract as two reStructuredText tables, to be included in the documentation

Return type:

str

pymodaq_utils.plugin_tools.contract.legacy_names(kind)[source]

Deprecated names still accepted in place of the mandatory methods: {method name: old name}

Return type:

dict[str, str]

pymodaq_utils.plugin_tools.contract.mandatory_methods(kind)[source]

Names of the methods that a plugin has to override

Return type:

tuple[str, ...]

pymodaq_utils.plugin_tools.contract.methods_of(kind)[source]

All the methods of the contract of an actuator (‘move’) or of a detector (‘viewer’)

Return type:

tuple[PluginMethod, ...]

pymodaq_utils.plugin_tools.contract.recommended_methods(kind)[source]

Names of the other methods of the contract: to override when the instrument can do it

Return type:

tuple[str, ...]