'Find a plugin named name'

def find_plugin(self, name, mod_type='', ignore_deprecated=False):

    if mod_type:
        suffix = mod_type
    elif self.class_name:
        suffix = '.py'
    else:
        suffix = ''
    pull_cache = self._plugin_path_cache[suffix]
    try:
        return pull_cache[name]
    except KeyError:
        pass
    for path in (p for p in self._get_paths() if ((p not in self._searched_paths) and os.path.isdir(p))):
        try:
            full_paths = (os.path.join(path, f) for f in os.listdir(path))
        except OSError as e:
            display.warning(('Error    accessing    plugin    paths:    %s' % to_text(e)))
        for full_path in (f for f in full_paths if (os.path.isfile(f) and (not f.endswith('__init__.py')))):
            full_name = os.path.basename(full_path)
            if full_path.endswith(('.pyc', '.pyo')):
                continue
            splitname = os.path.splitext(full_name)
            base_name = splitname[0]
            try:
                extension = splitname[1]
            except IndexError:
                extension = ''
            if (base_name not in self._plugin_path_cache['']):
                self._plugin_path_cache[''][base_name] = full_path
            if (full_name not in self._plugin_path_cache['']):
                self._plugin_path_cache[''][full_name] = full_path
            if (base_name not in self._plugin_path_cache[extension]):
                self._plugin_path_cache[extension][base_name] = full_path
            if (full_name not in self._plugin_path_cache[extension]):
                self._plugin_path_cache[extension][full_name] = full_path
        self._searched_paths.add(path)
        try:
            return pull_cache[name]
        except KeyError:
            pass
    if (not name.startswith('_')):
        alias_name = ('_' + name)
        if (alias_name in pull_cache):
            if ((not ignore_deprecated) and (not os.path.islink(pull_cache[alias_name]))):
                display.deprecated(('%s    is    kept    for    backwards    compatibility    but    usage    is    discouraged.    The    module    documentation    details    page    may    explain    more    about    this    rationale.' % name.lstrip('_')))
            return pull_cache[alias_name]
    return None
