(base_class, plugin_uid_prefix, sizes=[])
Plugin factory.

    :param dash.base.BaseDashboardWidget base_class: Subclass of.
    :param class base_class:
    :param string plugin_uid_prefix:
    :param list sizes:
    :param iterable sizes: Iterable of tuples.

    :example:
    >>> from dash.contrib.plugins.image.dash_plugins import BaseImagePlugin
    >>> plugin_factory(
    >>>     BaseImagePlugin, 'image', zip(range(6, 10), range(6, 10))
    >>> )

    The example above will update the plugin registry with the following
    dictionary:
    >>> {
    >>>     'image_6x6': dash.factory.Plugin,
    >>>     'image_7x7': dash.factory.Plugin,
    >>>     'image_8x8': dash.factory.Plugin,
    >>>     'image_9x9': dash.factory.Plugin,
    >>> }

    The generated class (one of them), would look as follows:

    >>> class Plugin(BaseImagePlugin):
    >>>     uid = 'image_6x6'

    The ``uid`` property is generated automatically.
Plugin factory.
Plugin factory .
def plugin_factory(base_class, plugin_uid_prefix, sizes=[]):
    """
    Plugin factory.

    :param dash.base.BaseDashboardWidget base_class: Subclass of.
    :param class base_class:
    :param string plugin_uid_prefix:
    :param list sizes:
    :param iterable sizes: Iterable of tuples.

    :example:
    >>> from dash.contrib.plugins.image.dash_plugins import BaseImagePlugin
    >>> plugin_factory(
    >>>     BaseImagePlugin, 'image', zip(range(6, 10), range(6, 10))
    >>> )

    The example above will update the plugin registry with the following
    dictionary:
    >>> {
    >>>     'image_6x6': dash.factory.Plugin,
    >>>     'image_7x7': dash.factory.Plugin,
    >>>     'image_8x8': dash.factory.Plugin,
    >>>     'image_9x9': dash.factory.Plugin,
    >>> }

    The generated class (one of them), would look as follows:

    >>> class Plugin(BaseImagePlugin):
    >>>     uid = 'image_6x6'

    The ``uid`` property is generated automatically.
    """
    for cols, rows in sizes:

        plugin_uid = "{plugin_uid_prefix}_{cols}x{rows}".format(
            plugin_uid_prefix=plugin_uid_prefix,
            cols=cols,
            rows=rows
        )

        class PluginMeta(type):
            """Dynamically created plugin plugin meta class."""

            def __new__(cls, name, bases, props):
                props['uid'] = plugin_uid
                return type.__new__(cls, name, bases, props)

        class Plugin(with_metaclass(PluginMeta, base_class)):
            """Dynamically created plugin class."""

        plugin_registry.register(Plugin)
def plugin_factory ( base_class , plugin_uid_prefix , sizes = [ ] ) : for cols , rows in sizes : plugin_uid = "{plugin_uid_prefix}_{cols}x{rows}" . format ( plugin_uid_prefix = plugin_uid_prefix , cols = cols , rows = rows ) class PluginMeta ( type ) : """Dynamically created plugin plugin meta class.""" def __new__ ( cls , name , bases , props ) : props [ 'uid' ] = plugin_uid return type . __new__ ( cls , name , bases , props ) class Plugin ( with_metaclass ( PluginMeta , base_class ) ) : """Dynamically created plugin class.""" plugin_registry . register ( Plugin )