# Path: cardinal/exceptions.py
# class CommandNotFoundError(CardinalException):
#     """Raised when a given command isn't loaded."""
# 
# class ConfigNotFoundError(CardinalException):
#     """Raised when an expected plugin config isn't found."""
# 
# class EventAlreadyExistsError(CardinalException):
#     """Raised durring attempt to register an event name already registered."""
# 
# class EventCallbackError(CardinalException):
#     """Raised when there is an error with a callback."""
# 
# class EventDoesNotExistError(CardinalException):
#     """Raised during attempt to register a callback for a nonexistent event."""
# 
# class EventRejectedMessage(CardinalException):
#     """Raised when an event callback wants to reject an event."""
# 
# class PluginError(CardinalException):
#     """Raised when a plugin is invalid in some way."""


import os
import re
import string
import logging
import importlib
import inspect
import linecache
import random
import json
from collections import defaultdict
from copy import copy
from importlib import reload
from cardinal.exceptions import (
    CommandNotFoundError,
    ConfigNotFoundError,
    EventAlreadyExistsError,
    EventCallbackError,
    EventDoesNotExistError,
    EventRejectedMessage,
    PluginError,
)
from twisted.internet import defer
        Raises:
          ConfigNotFoundError -- Raised when expected config isn't found.

        """
        # Initialize variable to hold plugin config
        config = None

        # Attempt to load and parse JSON config file
        file_ = os.path.join(
            self.plugins_directory,
            plugin,
            'config.json'
        )
        try:
            f = open(file_, 'r')
            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_
            )

        # If neither config was found, raise an exception
        if not config:

# Path: cardinal/exceptions.py
# class CommandNotFoundError(CardinalException):
#     """Raised when a given command isn't loaded."""
# 
# class ConfigNotFoundError(CardinalException):
#     """Raised when an expected plugin config isn't found."""
# 
# class EventAlreadyExistsError(CardinalException):
#     """Raised durring attempt to register an event name already registered."""
# 
# class EventCallbackError(CardinalException):
#     """Raised when there is an error with a callback."""
# 
# class EventDoesNotExistError(CardinalException):
#     """Raised during attempt to register a callback for a nonexistent event."""
# 
# class EventRejectedMessage(CardinalException):
#     """Raised when an event callback wants to reject an event."""
# 
# class PluginError(CardinalException):
#     """Raised when a plugin is invalid in some way."""


# Path: cardinal/plugins.py
import os
import re
import string
import logging
import importlib
import inspect
import linecache
import random
import json
from collections import defaultdict
from copy import copy
from importlib import reload
from cardinal.exceptions import (
    CommandNotFoundError,
    ConfigNotFoundError,
    EventAlreadyExistsError,
    EventCallbackError,
    EventDoesNotExistError,
    EventRejectedMessage,
    PluginError,
)
from twisted.internet import defer

        Raises:
          ConfigNotFoundError -- Raised when expected config isn't found.

        """
        # Initialize variable to hold plugin config
        config = None

        # Attempt to load and parse JSON config file
        file_ = os.path.join(
            self.plugins_directory,
            plugin,
            'config.json'
        )
        try:
            f = open(file_, 'r')
            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_
            )

        # If neither config was found, raise an exception
        if not config:

            raise ConfigNotFoundError(