def _load_plugin_config(self, plugin):
        """Loads a JSON or YAML config for a given plugin

        Keyword arguments:
          plugin -- Name of plugin to load config for.

        Raises:
          AmbiguousConfigError -- Raised when two configs exist for plugin.
          ConfigNotFoundError -- Raised when expected config isn't found.

        """
        # Initialize variable to hold plugin config
        json_config = False
        yaml_config = False

        # Attempt to load and parse JSON config file
        file = os.path.join(
            os.path.dirname(os.path.realpath(sys.argv[0])),
            'plugins',
            plugin,
            'config.json'
        )
        try:
            f = open(file, 'r')
            json_config = json.load(f)
            f.close()
        # File did not exist or we can't open it for another reason
        except IOError:
            self.logger.debug(
                "Can't open %s - maybe it doesn't exist?" % file
            )
        # Thrown by json.load() when the content isn't valid JSON
        except ValueError:
            self.logger.warning(
                "Invalid JSON in %s, skipping it" % file
            )

        # Attempt to load and parse YAML config file
        file = os.path.join(
            os.path.dirname(os.path.realpath(sys.argv[0])),
            'plugins',
            plugin,
            'config.yaml'
        )
        try:
            f = open(file, 'r')
            yaml_config = yaml.load(f)
            f.close()
        except __HOLE__:
            self.logger.debug(
                "Can't open %s - maybe it doesn't exist?" % file
            )
        except ValueError:
            self.logger.warning(
                "Invalid YAML in %s, skipping it" % file
            )
        # Loaded YAML successfully
        else:
            # If we already loaded JSON, this is a problem because we won't
            # know which config to use.
            if json_config:
                raise AmbiguousConfigError(
                    "Found both a JSON and YAML config for plugin"
                )

            # No JSON config, found YAML config, return it
            return yaml_config

        # If neither config was found, raise an exception
        if not yaml_config and not json_config:
            raise ConfigNotFoundError(
                "No config found for plugin: %s" % plugin
            )

        # Return JSON config, since YAML config wasn't found
        return json_config
dataset/ETHPy150Open JohnMaguire/Cardinal/cardinal/plugins.py/PluginManager._load_plugin_config