# Path: zabby/core/exceptions.py
# class ConfigurationError(Exception):
#     """ Something is wrong with configuration """
# 
# Path: zabby/core/six.py
# PY3 = sys.version_info[0] == 3
#     def b(s):
#     def u(s):
#     def b(s):
#     def u(s):


import imp
import os.path
import logging
import logging.config
from zabby.core.exceptions import ConfigurationError
from zabby.core.six import string_types, integer_types

LOG = logging.getLogger(__name__)


class ConfigManager:
    def __init__(self, config_path, config_loader):
        self._config_path = config_path
        self._config_loader = config_loader

        self._config = None
        self.listen_address = (None, None)
        self.items = dict()

    def update_config(self):
        """
        Reloads configuration from config_path binding

        :raises: ConfigurationError if configuration files are not valid python
        modules or if required module attributes are of wrong type
        """
        try:
            self._config = self._config_loader.load(self._config_path)
            logging.config.fileConfig(self._config.logging_conf,
                                      disable_existing_loggers=False)
            self._set_listen_address()
            self._load_items()
        except ConfigurationError as e:
            raise e
        except Exception as e:
            LOG.exception(e)

# Path: zabby/core/exceptions.py
# class ConfigurationError(Exception):
#     """ Something is wrong with configuration """
# 
# Path: zabby/core/six.py
# PY3 = sys.version_info[0] == 3
#     def b(s):
#     def u(s):
#     def b(s):
#     def u(s):


# Path: zabby/config_manager.py
import imp
import os.path
import logging
import logging.config
from zabby.core.exceptions import ConfigurationError
from zabby.core.six import string_types, integer_types


LOG = logging.getLogger(__name__)


class ConfigManager:
    def __init__(self, config_path, config_loader):
        self._config_path = config_path
        self._config_loader = config_loader

        self._config = None
        self.listen_address = (None, None)
        self.items = dict()

    def update_config(self):
        """
        Reloads configuration from config_path binding

        :raises: ConfigurationError if configuration files are not valid python
        modules or if required module attributes are of wrong type
        """
        try:
            self._config = self._config_loader.load(self._config_path)
            logging.config.fileConfig(self._config.logging_conf,
                                      disable_existing_loggers=False)
            self._set_listen_address()
            self._load_items()
        except ConfigurationError as e:
            raise e
        except Exception as e:
            LOG.exception(e)

            raise ConfigurationError()