def load(self, plugins):
        # If they passed in a string, convert it to a list (and encode the
        # name as UTF-8.)
        if isinstance(plugins, basestring):
            plugins = [plugins.encode('utf-8')]
        if not isinstance(plugins, list):
            raise TypeError(
                "Plugins argument must be a string or list of plugins"
            )

        # We'll keep track of plugins we failed to load (either because we)
        failed_plugins = []

        for plugin in plugins:
            # Reload flag so we can update the reload counter if necessary
            reload_flag = False

            self.logger.info("Attempting to load plugin: %s" % plugin)

            # Import each plugin's module with our own hacky function to reload
            # modules that have already been imported previously
            try:
                if plugin in self.plugins.keys():
                    self.logger.info("Already loaded, reloading: %s" % plugin)
                    reload_flag = True

                    try:
                        self._close_plugin_instance(plugin)
                    except Exception:
                        self.logger.exception(
                            "Didn't close plugin cleanly: %s" % plugin
                        )
                    module_to_import = self.plugins[plugin]['module']
                else:
                    module_to_import = plugin

                module = self._import_module(module_to_import)
            except Exception:
                # Probably a syntax error in the plugin, log the exception
                self.logger.exception(
                    "Could not load plugin module: %s" % plugin
                )
                failed_plugins.append(plugin)

                continue

            # Attempt to load the config file for the given plugin.
            config = None
            try:
                config = self._load_plugin_config(plugin)
            except AmbiguousConfigError:
                # If two configs exist for the plugin, bail on loading
                self.logger.exception("Could not load plugin: %s" % plugin)
                failed_plugins.append(plugin)

                continue
            except ConfigNotFoundError:
                self.logger.debug(
                    "No config found for plugin: %s" % plugin
                )

            # Instance the plugin
            try:
                instance = self._create_plugin_instance(module, config)
            except Exception:
                self.logger.exception(
                    "Could not instantiate plugin: %s" % plugin
                )
                failed_plugins.append(plugin)

                continue

            commands = self._get_plugin_commands(instance)
            callbacks = self._get_plugin_callbacks(instance)

            try:
                callback_ids = self._register_plugin_callbacks(callbacks)
            except Exception:
                self.logger.exception(
                    "Could not register events for plugin: %s" % plugin
                )
                failed_plugins.append(plugin)

                continue

            if plugin in self.plugins:
                self.unload(plugin)

            self.plugins[plugin] = {
                'name': plugin,
                'module': module,
                'instance': instance,
                'commands': commands,
                'callbacks': callbacks,
                'callback_ids': callback_ids,
                'config': config,
                'blacklist': [],
            }

            if reload_flag:
                self.cardinal.reloads += 1

            self.logger.info("Plugin %s successfully loaded" % plugin)

        return failed_plugins
Initialise capture file.
dataset/ETHPy150Open JohnMaguire/Cardinal/cardinal/plugins.py/PluginManager.load--crossover with--dataset/ETHPy150Open kisom/pypcapfile/pcapfile/test/linklayer_test.py/TestCase.init_capfile