def add(self, plugindir):
        root_exc_collection = []
        sub_exc_collection = []
        added = []

        try:
            # Add as if plugindir is the actual plugin
            added.append(self._add_plugin(plugindir))

            return added
        except PluginError as pe:
            root_exc_collection.append(pe)

        # Walk the directory, try to add each sub-directory as a plugin
        for dirname in listdir(plugindir):
            subdir = join(plugindir, dirname)
            if not isdir(subdir) or dirname == '.git':
                continue
            try:
                added.append(self._add_plugin(subdir))
            except PluginError as pe:
                sub_exc_collection.append(pe)

        if added:
            return added

        exc_collection = sub_exc_collection or root_exc_collection

        # If we haven't added any plugins and we have an exception raise it
        raise exc_collection[0]
Add the given plugin or directory of plugins to this manager instance.
dataset/ETHPy150Open robmadole/jig/src/jig/plugins/manager.py/PluginManager.add