def locatePlugins(self):
        """
        Walk through the plugins' places and look for plugins.

        Return the candidates and number of plugins found.
        """
        _candidates = []
        _discovered = {}
        for directory in map(os.path.abspath, self.plugins_places):
            # first of all, is it a directory :)
            if not os.path.isdir(directory):
                log.debug("%s skips %s (not a directory)" % (self.__class__.__name__, directory))
                continue
            if self.recursive:
                debug_txt_mode = "recursively"
                walk_iter = os.walk(directory, followlinks=True)
            else:
                debug_txt_mode = "non-recursively"
                walk_iter = [(directory,[],os.listdir(directory))]
            # iteratively walks through the directory
            log.debug((self.__class__.__name__, debug_txt_mode, directory) % "%s walks (%s) into directory: %s")
            for item in walk_iter:
                dirpath = item[0]
                for filename in item[2]:
                    for analyzer in self._analyzers:
                        # eliminate the obvious non plugin files
                        if not analyzer.isValidPlugin(filename):
                            log.debug("%s is not a valid plugin for strategy %s" % (filename, analyzer.name))
                            continue
                        candidate_infofile = os.path.join(dirpath, filename)
                        if candidate_infofile in _discovered:
                            log.debug("%s (with strategy %s) rejected because already discovered" % (candidate_infofile, analyzer.name))
                            continue
                        log.debug("%s found a candidate:\n    %s" % (self.__class__.__name__, candidate_infofile))
                        plugin_info = self._getInfoForPluginFromAnalyzer(analyzer, dirpath, filename)
                        if plugin_info is None:
                            log.warning("Plugin candidate '%s'  rejected by strategy '%s'" % (candidate_infofile, analyzer.name))
                            break # we consider this was the good strategy to use for: it failed -> not a plugin -> don't try another strategy
                        # now determine the path of the file to execute,
                        # depending on wether the path indicated is a
                        # directory or a file
                        # Remember all the files belonging to a discovered
                        # plugin, so that strategies (if several in use) won't
                        # collide
                        if os.path.isdir(plugin_info.path):
                            candidate_filepath = os.path.join(plugin_info.path, "__init__")
                            # it is a package, adds all the files concerned
                            for _file in os.listdir(plugin_info.path):
                                if _file.endswith(".py"):
                                    self._discovered_plugins[os.path.join(plugin_info.path, _file)] = candidate_filepath
                                    _discovered[os.path.join(plugin_info.path, _file)] = candidate_filepath
                        elif (plugin_info.path.endswith(".py") and os.path.isfile(plugin_info.path)) or os.path.isfile(plugin_info.path+".py"):
                            candidate_filepath = plugin_info.path
                            if candidate_filepath.endswith(".py"):
                                candidate_filepath = candidate_filepath[:-3]
                            # it is a file, adds it
                            self._discovered_plugins[".".join((plugin_info.path, "py"))] = candidate_filepath
                            _discovered[".".join((plugin_info.path, "py"))] = candidate_filepath
                        else:
                            log.error("Plugin candidate rejected: cannot find the file or directory module for '%s'" % (candidate_infofile))
                            break
                        _candidates.append((candidate_infofile, candidate_filepath, plugin_info))
                        # finally the candidate_infofile must not be discovered again
                        _discovered[candidate_infofile] = candidate_filepath
                        self._discovered_plugins[candidate_infofile] = candidate_filepath
        return _candidates, len(_candidates)
dataset/ETHPy150Open datamachine/telex/telex/plugin/PluginFileLocator.py/PluginFileLocator.locatePlugins/swapped operands of `%`