def plugins_dict(module, plugin_type_identifier):
 plugin_dict = {}
 for plugin_module in submodules(module):
  for clazz in getattr(plugin_module, '__all__', []):
   try:
    clazz = getattr(plugin_module, clazz)
   except TypeError:
    clazz = clazz
   plugin_type = getattr(clazz, plugin_type_identifier, None)
   if plugin_type:
    plugin_dict[plugin_type] = clazz
 return plugin_dict

def plugins_dict ( module , plugin_type_identifier ) : plugin_dict = { } for plugin_module in submodules ( module ) : for clazz in getattr ( plugin_module , '__all__' , [ ] ) : try : clazz = getattr ( plugin_module , clazz ) except TypeError : clazz = clazz plugin_type = getattr ( clazz , plugin_type_identifier , None ) if plugin_type : plugin_dict [ plugin_type ] = clazz return plugin_dict
walk through all classes in submodules of module and find ones labelled with specified plugin_type_identifier and throw in a dictionary to allow constructions from plugins by these types later on .