'Scan the plugin directories for plugins we could load.
This updates the global PluginManager state and returns the
PluginManager itself (for chaining).'

def discover(self, paths, update=False):

    plugins = self.BUILTIN[:]
    for pdir in paths:
        for subdir in self._listdir(pdir):
            pname = subdir.lower()
            if (pname in self.BUILTIN):
                print ('Cannot    overwrite    built-in    plugin:    %s' % pname)
                continue
            if ((pname in self.DISCOVERED) and (not update)):
                continue
            plug_path = os.path.join(pdir, subdir)
            manifest_filename = os.path.join(plug_path, 'manifest.json')
            try:
                with open(manifest_filename) as mfd:
                    manifest = json.loads(self._uncomment(mfd.read()))
                    assert (manifest.get('name') == subdir)
                    self.DISCOVERED[pname] = (plug_path, manifest)
            except (ValueError, AssertionError):
                print ('Bad    manifest:    %s' % manifest_filename)
            except (OSError, IOError):
                pass
    return self
