# Path: baroque/defaults/config.py
# DEFAULT_CONFIG = {
#     'eventtypes': {
#         'ignore_unregistered': True,
#         'pre_registered': [
#             'baroque.defaults.eventtypes.GenericEventType',
#             'baroque.defaults.eventtypes.StateTransitionEventType',
#             'baroque.defaults.eventtypes.DataOperationEventType',
#             'baroque.defaults.eventtypes.MetricEventType'
#         ]
#     },
#     'events': {
#         'validate_schema': True,
#         'persist': False,
#         'persistence_backend': 'baroque.persistence.inmemory.DictBackend'
#     },
#     'reactors': {
#         'propagate_exceptions': True
#     },
#     'topics': {
#         'register_on_binding': True
#     }
# }
# 
# Path: baroque/exceptions/configuration.py
# class ConfigurationNotFoundError(Exception):
# class ConfigurationParseError(Exception):


import os
import yaml
from baroque.defaults.config import DEFAULT_CONFIG
from baroque.exceptions import configuration

    """
    if path_to_file is None:
        return DEFAULT_CONFIG
    return readconfig(path_to_file)


def readconfig(path_to_file):
    """Loads configuration data from the supplied file.

    Args:
        path_to_file (str, optional): Path to the configuration file.

    Returns:
        dict: The configuration dictionary

    Raises:
        (:obj:`baroque.exceptions.configuration.ConfigurationNotFoundError`:
        when the supplied filepath is not a regular file
        (:obj:`baroque.exceptions.configuration.ConfigurationParseError`:
        when the supplied file cannot be parsed

    """
    if not os.path.isfile(path_to_file):
        raise configuration.ConfigurationNotFoundError(
            'Configuration file not found: {}'.format(path_to_file))
    with open(path_to_file, 'r') as cf:
        try:
            return yaml.load(cf)
        except yaml.YAMLError:

# Path: baroque/defaults/config.py
# DEFAULT_CONFIG = {
#     'eventtypes': {
#         'ignore_unregistered': True,
#         'pre_registered': [
#             'baroque.defaults.eventtypes.GenericEventType',
#             'baroque.defaults.eventtypes.StateTransitionEventType',
#             'baroque.defaults.eventtypes.DataOperationEventType',
#             'baroque.defaults.eventtypes.MetricEventType'
#         ]
#     },
#     'events': {
#         'validate_schema': True,
#         'persist': False,
#         'persistence_backend': 'baroque.persistence.inmemory.DictBackend'
#     },
#     'reactors': {
#         'propagate_exceptions': True
#     },
#     'topics': {
#         'register_on_binding': True
#     }
# }
# 
# Path: baroque/exceptions/configuration.py
# class ConfigurationNotFoundError(Exception):
# class ConfigurationParseError(Exception):


# Path: baroque/utils/configreader.py
import os
import yaml
from baroque.defaults.config import DEFAULT_CONFIG
from baroque.exceptions import configuration


    """
    if path_to_file is None:
        return DEFAULT_CONFIG
    return readconfig(path_to_file)


def readconfig(path_to_file):
    """Loads configuration data from the supplied file.

    Args:
        path_to_file (str, optional): Path to the configuration file.

    Returns:
        dict: The configuration dictionary

    Raises:
        (:obj:`baroque.exceptions.configuration.ConfigurationNotFoundError`:
        when the supplied filepath is not a regular file
        (:obj:`baroque.exceptions.configuration.ConfigurationParseError`:
        when the supplied file cannot be parsed

    """
    if not os.path.isfile(path_to_file):
        raise configuration.ConfigurationNotFoundError(
            'Configuration file not found: {}'.format(path_to_file))
    with open(path_to_file, 'r') as cf:
        try:
            return yaml.load(cf)
        except yaml.YAMLError:

            raise configuration.ConfigurationParseError()