Grapher Builder

The grapher_builder module defines the plug-in infrastructure shared by all graphers. Every grapher must inherit from BaseClass and implement the required interface; GrapherFactory() discovers and instantiates the correct subclass at runtime from a plain string name.

Grapher BaseClass

class ecosound.visualization.grapher_builder.BaseClass(grapher_name)[source]

Bases: object

Base class for all graphers.

All graphers need to inheritate from this BaseClass in order to be built by the GrapherFactory.

classmethod is_grapher_for(grapher_name)[source]

Check grapher name.

Compare the requested grapher_name with each grapher class available.

Parameters:
  • grapher_name (str)

  • class. (Name of the grapher)

Return type:

bool

GrapherFactory

ecosound.visualization.grapher_builder.GrapherFactory(grapher_name, *args, **kwargs)[source]

Grapher Factory.

Loads the grapher class defined by grapher_name. Each grapher class must be added to the __init__.py file.

For example : from .grapher1 import Grapher1

where Grapher1 is the name of the grapher class to load from the .py file grapher1

Parameters:
  • grapher_name (str) – Name of the grapher class.

  • *args (any) – Input arguments for the grapher selected.

  • **kwargs (any) – Keyword arguments for the grapher selected.

Raises:

ValueError – If grapher_name doesn’t correspond to any of the graphers available.

Return type:

Grapher object