Import and register plugin in the plugin manager.

        The pluggy library is used as plugin manager.
433544
def _import_plugins(self) -> None:
        
        logger.debug('Importing plugins')
        self._pm = pluggy.PluginManager('sirbot')
        self._pm.add_hookspecs(hookspecs)

        for plugin in self.config['sirbot']['plugins']:
            try:
                p = importlib.import_module(plugin)
            except (ModuleNotFoundError, ):
                if os.getcwd() not in sys.path:
                    sys.path.append(os.getcwd())
                    p = importlib.import_module(plugin)
                else:
                    raise
            self._pm.register(p)
269839
def register(self, value):
        
        if self.env is None:
            raise PluginException('The plugin must be installed to application.')

        def wrapper(func):
            name = func.__name__
            if isinstance(value, str):
                name = value
            if callable(func):
                self.env.globals[name] = func
            return func

        if callable(value):
            return wrapper(value)

        return wrapper
521262
def register_plugin(self):
        """"""
        self.focus_changed.connect(self.main.plugin_focus_changed)
        self.main.add_dockwidget(self)
        self.ipyconsole = self.main.ipyconsole
        self.create_new_client(give_focus=False)
        icon_path = os.path.join(PACKAGE_PATH, 'images', 'icon.svg')
        self.main.add_to_fileswitcher(self, self.tabwidget, self.clients,
                                      QIcon(icon_path))
        self.recent_notebook_menu.aboutToShow.connect(self.setup_menu_actions)
1243563
def install(self, plugin, name=None, **opts):
        """"""
        source = plugin

        if isinstance(plugin, str):
            module, _, attr = plugin.partition(':')
            module = import_module(module)
            plugin = getattr(module, attr or 'Plugin', None)

        if isinstance(plugin, types.ModuleType):
            plugin = getattr(module, 'Plugin', None)

        if plugin is None:
            raise MuffinException('Plugin is not found %r' % source)

        name = name or plugin.name
        if name in self.ps:
            raise MuffinException('Plugin with name `%s` is already intalled.' % name)

        if isinstance(plugin, type):
            plugin = plugin(**opts)

        if hasattr(plugin, 'setup'):
            plugin.setup(self)

        if hasattr(plugin, 'middleware') and plugin.middleware not in self.middlewares:
            self.middlewares.append(plugin.middleware)

        if hasattr(plugin, 'startup'):
            self.on_startup.append(plugin.startup)

        if hasattr(plugin, 'cleanup'):
            self.on_cleanup.append(plugin.cleanup)

        # Save plugin links
        self.ps[name] = plugin

        return plugin
201567
def register_default_plugins(root_parser: ParserRegistryWithConverters):
    
    # -------------------- CORE ---------------------------
    try:
        # -- primitive types
        from parsyfiles.plugins_base.support_for_primitive_types import get_default_primitive_parsers, \
            get_default_primitive_converters
        root_parser.register_parsers(get_default_primitive_parsers())
        root_parser.register_converters(get_default_primitive_converters())
    except ImportError as e:
        warn_import_error('primitive types', e)
    try:
        # -- collections
        from parsyfiles.plugins_base.support_for_collections import get_default_collection_parsers, \
            get_default_collection_converters
        root_parser.register_parsers(get_default_collection_parsers(root_parser, root_parser))
        root_parser.register_converters(get_default_collection_converters(root_parser))
    except ImportError as e:
        warn_import_error('dict', e)
    try:
        # -- objects
        from parsyfiles.plugins_base.support_for_objects import get_default_object_parsers, \
            get_default_object_converters
        root_parser.register_parsers(get_default_object_parsers(root_parser, root_parser))
        root_parser.register_converters(get_default_object_converters(root_parser))
    except ImportError as e:
        warn_import_error('objects', e)
    try:
        # -- config
        from parsyfiles.plugins_base.support_for_configparser import get_default_config_parsers, \
            get_default_config_converters
        root_parser.register_parsers(get_default_config_parsers())
        root_parser.register_converters(get_default_config_converters(root_parser))
    except ImportError as e:
        warn_import_error('config', e)

    # ------------------------- OPTIONAL -----------------
    try:
        # -- jprops
        from parsyfiles.plugins_optional.support_for_jprops import get_default_jprops_parsers
        root_parser.register_parsers(get_default_jprops_parsers(root_parser, root_parser))
        # root_parser.register_converters()
    except ImportError as e:
        warn_import_error('jprops', e)
    try:
        # -- yaml
        from parsyfiles.plugins_optional.support_for_yaml import get_default_yaml_parsers
        root_parser.register_parsers(get_default_yaml_parsers(root_parser, root_parser))
        # root_parser.register_converters()
    except ImportError as e:
        warn_import_error('yaml', e)
    try:
        # -- numpy
        from parsyfiles.plugins_optional.support_for_numpy import get_default_np_parsers, get_default_np_converters
        root_parser.register_parsers(get_default_np_parsers())
        root_parser.register_converters(get_default_np_converters())
    except ImportError as e:
        warn_import_error('numpy', e)
    try:
        # -- pandas
        from parsyfiles.plugins_optional.support_for_pandas import get_default_pandas_parsers, \
            get_default_pandas_converters
        root_parser.register_parsers(get_default_pandas_parsers())
        root_parser.register_converters(get_default_pandas_converters())
    except ImportError as e:
        warn_import_error('pandas', e)
32413
def import_plugin(path_or_url)
      raise "`import_plugin` requires a string" unless path_or_url.kind_of?(String)

      if path_or_url.start_with?("http")
        import_url(path_or_url)
      else
        import_local(path_or_url)
      end
    end
639879
def _load_plugins(self):
        '''
        
        '''
        plugins = self.settings['PLUGINS']

        self.plugins_dict = {}
        for key in plugins:
            # skip loading the plugin if its value is None
            if plugins[key] is None:
                continue
            # valid plugin, import and setup
            self.logger.debug("Trying to load plugin {cls}".format(cls=key))
            the_class = self._import_class(key)
            instance = the_class()
            instance._set_logger(self.logger)
            if not self.unit_test:
                instance.setup(self.settings)
            the_schema = None
            with open(self.settings['PLUGIN_DIR'] + instance.schema) as the_file:
                the_schema = json.load(the_file)

            mini = {}
            mini['instance'] = instance
            mini['schema'] = the_schema
            self.logger.debug("Successfully loaded plugin {cls}".format(cls=key))
            self.plugins_dict[plugins[key]] = mini

        self.plugins_dict = OrderedDict(sorted(list(self.plugins_dict.items()),
                                               key=lambda t: t[0]))
1153780
def RegisterPlugin(cls, plugin_class):
    
    plugin_name = plugin_class.NAME.lower()
    if plugin_name in cls._plugin_classes:
      raise KeyError((
          'Plugin class already set for name: {0:s}.').format(
              plugin_class.NAME))

    cls._plugin_classes[plugin_name] = plugin_class
145308
def load_plugins(self):
        
        try:
            from pkg_resources import iter_entry_points
        except ImportError:
            return
        for ep in iter_entry_points(group="custodian.%s" % self.plugin_type):
            f = ep.load()
            f()
472716
def load_all_plugins(self):
        """"""

        # Go through the existing python files in the plugin directory
        self.plugin_path = os.path.realpath(self.plugin_dir)
        sys.path.append(self.plugin_dir)
        print '<<< Plugin Manager >>>'
        for f in [os.path.join(self.plugin_dir, child) for child in os.listdir(self.plugin_dir)]:

            # Skip certain files
            if '.DS_Store' in f or '__init__.py' in f: 
                continue

            # Add the plugin
            self.add_plugin(f)
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)
887942
def register_plugin(self):
        """"""
        self.focus_changed.connect(self.main.plugin_focus_changed)
        self.main.add_dockwidget(self)
        # Connecting the following signal once the dockwidget has been created:
        self.shell.exception_occurred.connect(self.exception_occurred)
330828
def add_library(self, library):
        
        for fn in library.__dict__.copy().values():
            # ignore imported methods and anything beginning __
            if inspect.isfunction(fn) and inspect.getmodule(fn) == library and not fn.__name__.startswith('__'):
                name = fn.__name__.lower()

                # strip preceding _ chars used to avoid conflicts with Java keywords
                if name.startswith('_'):
                    name = name[1:]

                self._functions[name] = fn
416244
def install(self, plugin):
        ''' 
        '''
        if hasattr(plugin, 'setup'): plugin.setup(self)
        if not callable(plugin) and not hasattr(plugin, 'apply'):
            raise TypeError("Plugins must be callable or implement .apply()")
        self.plugins.append(plugin)
        self.reset()
        return plugin
605443
public function registerPlugins()
    {
        $jsonFile = Environment::getJsonConfigFilename();
        if (!$jsonFile) {
            return;
        }

        $config = new Config;
        $var    = $config->validate($jsonFile);

        foreach ($var['plugins'] as $plugin) {
            if (class_exists($plugin['class'])) {
                if (isset($plugin['options'])) {
                    $options = $plugin['options'];
                    if (is_string($options)) {
                        if (class_exists($options)) {
                            $options = new $options;
                        } else {
                            $options = null;
                        }
                    }
                } else {
                    $options = null;
                }
                $plugin = new $plugin['class']($options);

                if ($plugin instanceof PluginInterface) {
                    $this->addPlugin($plugin);
                }
            }
        }
    }
1215578
def register_plugins(cls, plugins):
        '''
        
        '''
        for model in plugins:
            cls.register_plugin(model, plugins[model])
1029091
function (ui, done) {
        Object.keys(ui.defaultPlugins).forEach(function (key) {
            ui.pluginManager.get(key)(ui, ui.bs);
        });
        done();
    }