pluggable

compas.plugins.pluggable(pluggable_method=None, category=None, selector='first_match', domain='https://plugins.compas.dev/')[source]

Decorator to mark a method as a pluggable extension point.

A pluggable interface is uniquely identifiable/locatable via a URL derived from the parameters domain, category and name pluggable_method. In the example below, the URL of the pluggable definition is:

https://plugins.compas.dev/triangulation/triangulate_mesh
Parameters:
pluggable_methodcallable

The method to decorate as pluggable.

categorystr, optional

An optional string to group or categorize extension points.

selectorstr, optional

String that determines the selection mode of extension points.

  • "first_match": (str) Execute the first matching implementation.

  • "collect_all": (str) Executes all matching implementations and return list of its return values.

domainstr, optional

Domain name that “owns” the pluggable extension point. This is useful to avoid name collisions between extension points of different packages.

Examples

>>> @pluggable(category='triangulation')
... def triangulate_mesh(mesh):
...    pass