def load_plugin_classes(classes, category=None, overwrite=False):
    """ load plugins from class objects

    Parameters
    ----------
    classes: list
        list of classes
    category : None or str
        if str, apply for single plugin category
    overwrite : bool
        if True, allow existing plugins to be overwritten

    Examples
    --------

    >>> from pprint import pprint
    >>> pprint(view_plugins())
    {'decoders': {}, 'encoders': {}, 'parsers': {}}

    >>> class DecoderPlugin(object):
    ...     plugin_name = 'example'
    ...     plugin_descript = 'a decoder for dicts containing _example_ key'
    ...     dict_signature = ('_example_',)
    ...
    >>> errors = load_plugin_classes([DecoderPlugin])

    >>> pprint(view_plugins())
    {'decoders': {'example': 'a decoder for dicts containing _example_ key'},
     'encoders': {},
     'parsers': {}}

    >>> unload_all_plugins()

    """
    load_errors = []
    for klass in classes:
        for pcat, pinterface in _plugins_interface.items():
            if category is not None and not pcat == category:
                continue
            if all([hasattr(klass, attr) for attr in pinterface]):
                if klass.plugin_name in _all_plugins[pcat] and not overwrite:
                    err = '{0} is already set for {1}'.format(
                        klass.plugin_name, pcat)
                    load_errors.append((klass.__name__, '{}'.format(err)))
                    continue
                _all_plugins[pcat][klass.plugin_name] = klass()
            else:
                load_errors.append((
                    klass.__name__,
                    'does not match {} interface: {}'.format(pcat, pinterface)
                ))
    return load_errors
def load_plugin_classes ( classes , category = None , overwrite = False ) : load_errors = [ ] for klass in classes : for pcat , pinterface in _plugins_interface . items ( ) : if category is not None and not pcat == category : continue if all ( [ hasattr ( klass , attr ) for attr in pinterface ] ) : if klass . plugin_name in _all_plugins [ pcat ] and not overwrite : err = '{0} is already set for {1}' . format ( klass . plugin_name , pcat ) load_errors . append ( ( klass . __name__ , '{}' . format ( err ) ) ) continue _all_plugins [ pcat ] [ klass . plugin_name ] = klass ( ) else : load_errors . append ( ( klass . __name__ , 'does not match {} interface: {}' . format ( pcat , pinterface ) ) ) return load_errors
load plugins from class objects

    Parameters
    ----------
    classes: list
        list of classes
    category : None or str
        if str, apply for single plugin category
    overwrite : bool
        if True, allow existing plugins to be overwritten

    Examples
    --------

    >>> from pprint import pprint
    >>> pprint(view_plugins())
    {'decoders': {}, 'encoders': {}, 'parsers': {}}

    >>> class DecoderPlugin(object):
    ...     plugin_name = 'example'
    ...     plugin_descript = 'a decoder for dicts containing _example_ key'
    ...     dict_signature = ('_example_',)
    ...
    >>> errors = load_plugin_classes([DecoderPlugin])

    >>> pprint(view_plugins())
    {'decoders': {'example': 'a decoder for dicts containing _example_ key'},
     'encoders': {},
     'parsers': {}}

    >>> unload_all_plugins()