Discover the plugin classes contained in Python files.

    Parameters
    ----------

    dirs : list
        List of directory names to scan.

    Returns
    -------

    plugins : list
        List of plugin classes.
768534
def discover_plugins(dirs):
    
    # Scan all subdirectories recursively.
    for path in _iter_plugin_files(dirs):
        filename = op.basename(path)
        subdir = op.dirname(path)
        modname, ext = op.splitext(filename)
        file, path, descr = imp.find_module(modname, [subdir])
        if file:
            # Loading the module registers the plugin in
            # IPluginRegistry.
            try:
                mod = imp.load_module(modname, file, path, descr)  # noqa
            except Exception as e:  # pragma: no cover
                logger.exception(e)
            finally:
                file.close()
    return IPluginRegistry.plugins
678372
def get_tools(whitelist, known_plugins):
    
    def getpath(c):
        return "%s:%s" % (c.__module__, c.__class__.__name__)

    tools = [x for x in known_plugins if getpath(x) in whitelist]

    if not tools:
        if whitelist:
            raise UnknownTools(map(getpath, known_plugins))
        tools = known_plugins
    return tools
1318804
def _filter_modules(self, plugins, names):
        
        if self.module_plugin_filters:
            # check to make sure the number of plugins isn't changing
            original_length_plugins = len(plugins)
            module_plugins = set()
            for module_filter in self.module_plugin_filters:
                module_plugins.update(module_filter(plugins, names))
                if len(plugins) < original_length_plugins:
                    warning = """Module Filter removing plugins from original
                    data member! Suggest creating a new list in each module
                    filter and returning new list instead of modifying the
                    original data member so subsequent module filters can have
                    access to all the possible plugins.\n {}"""

                    self._log.info(warning.format(module_filter))

            plugins = module_plugins
        return plugins
902257
def get_plugins():
    """"""
    if os.path.exists('plugins'):
        for filename in sorted([f for f in os.listdir('plugins')
                if not os.path.isdir(f) and f.endswith(".py")]):
            plugin_name = filename[:-3]
            try:
                plugin = import_plugin(plugin_name)
            except SystemExit as e:
                description = "Plugin has a syntax error"
            else:
                description = plugin.__doc__ or "No description found"
            yield {plugin_name: description}
29531
def find_plugin(self, name):
        """"""
        suffix = ".py"
        if not self.class_name:
            suffix = ""
        for i in self._get_paths():
            path = os.path.join(i, "%s%s" % (name, suffix))
            if os.path.exists(path):
                return path
        return None
583633
def GetPluginObjects(cls, plugin_names):
    
    plugin_objects = {}
    for plugin_name, plugin_class in iter(cls._plugin_classes.items()):
      if plugin_name not in plugin_names:
        continue

      plugin_objects[plugin_name] = plugin_class()

    return plugin_objects
1226345
def list_local_plugins(plugin_type, plugins_path, plugin_details):
    """"""
    installed_plugins = list()
    for plugin in next(os.walk(plugins_path))[1]:
        s = plugin_details(plugin)
        installed_plugins.append(plugin)
        click.secho(s)

    if not installed_plugins:
        click.secho("[*] You do not have any {0}s installed, "
                    "try installing one with `honeycomb {0} install`".format(plugin_type))

    return installed_plugins
676956
def discover_plugin(module_path)
        plugin = plugin_classes.find {|c| c.send(:valid_module_dir?, module_path) }
        raise NoSuitablePluginFoundException unless plugin
        plugin
     end
1367011
def __scanPlugins(self):
        
        self.logger.info("Initialization Plugins Start, local plugins path: %s, third party plugins: %s" % (self.plugins_abspath, self.plugin_packages))

        #: Load third-party plugins
        if self.plugin_packages and isinstance(self.plugin_packages, (list, tuple)):
            for package_name in self.plugin_packages:
                try:
                    plugin = __import__(package_name)
                except ImportError as e:
                    raise PluginError("ImportError for %s, detail is %s" %(package_name, e))
                else:
                    plugin_abspath = os.path.dirname(os.path.abspath(plugin.__file__))
                    self.__loadPlugin(plugin, plugin_abspath, package_name)

        #: Load local plug-in directory
        if os.path.isdir(self.plugins_abspath) and os.path.isfile(os.path.join(self.plugins_abspath, "__init__.py")):
            for package_name in os.listdir(self.plugins_abspath):
                package_abspath = os.path.join(self.plugins_abspath, package_name)
                if os.path.isdir(package_abspath) and os.path.isfile(os.path.join(package_abspath, "__init__.py")):
                    self.logger.info("find plugin package: %s" % package_name)
                    #: Dynamic load module (plugins.package): you can query custom information and get the plugin's class definition through getPluginClass
                    plugin = __import__("{0}.{1}".format(self.plugins_folder, package_name), fromlist=[self.plugins_folder, ])
                    self.__loadPlugin(plugin, package_abspath, package_name)
996065
def load_builtin_plugins() -> int:
    
    plugin_dir = os.path.join(os.path.dirname(__file__), 'plugins')
    return load_plugins(plugin_dir, 'nonebot.plugins')
502111
def plugin_classes
       unless @plugin_classes
         load_plugins
         @plugin_classes = ObjectSpace.each_object(Class).find_all { |c| c.name =~ /Retrospec::Plugins/} - excluded_classes || []
       end
       @plugin_classes
     end
570335
def find_class_files(self):
        
        files = self._find_files()
        self.announce(
            "found '{}' compiled class files in '{}'".format(
                len(files), self.root
            )
        )
        return files
1108981
def get_plugins_qs(cls):
        
        if is_plugin_point(cls):
            point_pythonpath = cls.get_pythonpath()
            return Plugin.objects.filter(point__pythonpath=point_pythonpath,
                                         status=ENABLED).\
                order_by('index')
        else:
            raise Exception(_('This method is only available to plugin point '
                              'classes.'))
318752
def getPlugins():
		
		
		# Retrieve the list of detected entry points in the ue4cli.plugins group
		plugins = {
			entry_point.name: entry_point.load()
			for entry_point
			in pkg_resources.iter_entry_points('ue4cli.plugins')
		}
		
		# Filter out any invalid plugins
		plugins = {
			name: plugins[name]
			for name in plugins
			if
				'action' in plugins[name] and
				'description' in plugins[name] and
				'args' in plugins[name] and
				callable(plugins[name]['action']) == True and
				len(signature(plugins[name]['action']).parameters) == 2
		}
		
		return plugins
508823
def __find_child_classes(self, file):
        

        child_classes = []
        folder, name = os.path.split(file)
        name = os.path.splitext(name)[0]

        import imp
        module = imp.load_source(name, file)

        def filter_classes(m):
            if inspect.isclass(m):
                if inspect.getmro(m)[1] == self.__base_class:
                    return True
            return False

        for name, obj in inspect.getmembers(module, filter_classes):
            child_classes.append(obj)

        return child_classes
216154
def plugins(self):
        
        from fluent_contents import extensions   # Avoid circular reference because __init__.py imports subfolders too
        if self._plugins is None:
            return extensions.plugin_pool.get_plugins()
        else:
            return extensions.plugin_pool.get_plugins_by_name(*self._plugins)
708498
def load_plugins(self, plugin_class_name):
        
        # imp.findmodule('atomic_reactor') doesn't work
        plugins_dir = os.path.join(os.path.dirname(__file__), 'plugins')
        logger.debug("loading plugins from dir '%s'", plugins_dir)
        files = [os.path.join(plugins_dir, f)
                 for f in os.listdir(plugins_dir)
                 if f.endswith(".py")]
        if self.plugin_files:
            logger.debug("loading additional plugins from files '%s'", self.plugin_files)
            files += self.plugin_files
        plugin_class = globals()[plugin_class_name]
        plugin_classes = {}
        for f in files:
            module_name = os.path.basename(f).rsplit('.', 1)[0]
            # Do not reload plugins
            if module_name in sys.modules:
                f_module = sys.modules[module_name]
            else:
                try:
                    logger.debug("load file '%s'", f)
                    f_module = imp.load_source(module_name, f)
                except (IOError, OSError, ImportError, SyntaxError) as ex:
                    logger.warning("can't load module '%s': %r", f, ex)
                    continue
            for name in dir(f_module):
                binding = getattr(f_module, name, None)
                try:
                    # if you try to compare binding and PostBuildPlugin, python won't match them
                    # if you call this script directly b/c:
                    # ! <class 'plugins.plugin_rpmqa.PostBuildRPMqaPlugin'> <= <class
                    # '__main__.PostBuildPlugin'>
                    # but
                    # <class 'plugins.plugin_rpmqa.PostBuildRPMqaPlugin'> <= <class
                    # 'atomic_reactor.plugin.PostBuildPlugin'>
                    is_sub = issubclass(binding, plugin_class)
                except TypeError:
                    is_sub = False
                if binding and is_sub and plugin_class.__name__ != binding.__name__:
                    plugin_classes[binding.key] = binding
        return plugin_classes