# Path: ratatosk/backend.py

# 
# Path: ratatosk/utils.py
# def update(d, u, override=True, expandvars=True):
#     """Update values of a nested dictionary of varying depth"""
#     for k, v in u.iteritems():
#         if isinstance(v, collections.Mapping):
#             r = update(d.get(k, {}), v)
#             d[k] = r
#         else:
#             if expandvars and isinstance(v, str):
#                 u[k] = os.path.expandvars(v)
#             d[k] = u[k]
#     return d
# 
# def config_to_dict(d):
#     """Convert config handler or OrderedDict entries to dict for yaml
#     output.
# 
#     :param d: config handler or ordered dict
#     """
#     if d is None:
#         return {}
#     if isinstance(d, dict):
#         pass
#     else:
#         raise TypeError("unsupported type <{}>".format(type(d)))
#     u = {}
#     for k, v in d.iteritems():
#         u[k] = {}
#         if isinstance(v, collections.Mapping):
#             for x, y in v.iteritems():
#                 if isinstance(y, collections.Mapping):
#                     u[k][x] = dict(y)
#                 else:
#                     u[k][x] = y
#         else:
#             u[k] = v
#     return u
# 
# Path: ratatosk/log.py
# def get_logger():
#     logger = logging.getLogger('ratatosk-interface')
#     if not logger.handlers:
#         setup_logging()
#     return logger


import os
import yaml
import logging
import collections
from ConfigParser import NoSectionError, NoOptionError, DuplicateSectionError
from ratatosk import backend
from ratatosk.utils import update, config_to_dict
from ratatosk.log import get_logger
    from collections import OrderedDict as _default_dict
        return cls._instance

    @classmethod
    def clear(cls):
        cls._instance._config_paths = []
        cls._instance._sections = cls._cls_dict()

    def reload(self):
        return self._instance.read(self._instance._config_paths)

    def __init__(self, defaults=None, dict_type=_default_dict, *args, **kw):
        self._dict = dict_type
        self._sections = self._dict()
        self._defaults = self._dict()
        _cls_dict = self._dict
    
    def read(self, file_paths):
        """
        Read config files.

        :param file_path: The file system path to the configuration file.

        :returns: boolean
        """
        for path in file_paths:
            try:
                with open(path) as fp:
                    _sections = yaml.load(fp)
                    if _sections is None:
                        _sections = {}

# Path: ratatosk/backend.py

# 
# Path: ratatosk/utils.py
# def update(d, u, override=True, expandvars=True):
#     """Update values of a nested dictionary of varying depth"""
#     for k, v in u.iteritems():
#         if isinstance(v, collections.Mapping):
#             r = update(d.get(k, {}), v)
#             d[k] = r
#         else:
#             if expandvars and isinstance(v, str):
#                 u[k] = os.path.expandvars(v)
#             d[k] = u[k]
#     return d
# 
# def config_to_dict(d):
#     """Convert config handler or OrderedDict entries to dict for yaml
#     output.
# 
#     :param d: config handler or ordered dict
#     """
#     if d is None:
#         return {}
#     if isinstance(d, dict):
#         pass
#     else:
#         raise TypeError("unsupported type <{}>".format(type(d)))
#     u = {}
#     for k, v in d.iteritems():
#         u[k] = {}
#         if isinstance(v, collections.Mapping):
#             for x, y in v.iteritems():
#                 if isinstance(y, collections.Mapping):
#                     u[k][x] = dict(y)
#                 else:
#                     u[k][x] = y
#         else:
#             u[k] = v
#     return u
# 
# Path: ratatosk/log.py
# def get_logger():
#     logger = logging.getLogger('ratatosk-interface')
#     if not logger.handlers:
#         setup_logging()
#     return logger


# Path: ratatosk/config.py
import os
import yaml
import logging
import collections
from ConfigParser import NoSectionError, NoOptionError, DuplicateSectionError
from ratatosk import backend
from ratatosk.utils import update, config_to_dict
from ratatosk.log import get_logger
    from collections import OrderedDict as _default_dict

        return cls._instance

    @classmethod
    def clear(cls):
        cls._instance._config_paths = []
        cls._instance._sections = cls._cls_dict()

    def reload(self):
        return self._instance.read(self._instance._config_paths)

    def __init__(self, defaults=None, dict_type=_default_dict, *args, **kw):
        self._dict = dict_type
        self._sections = self._dict()
        self._defaults = self._dict()
        _cls_dict = self._dict
    
    def read(self, file_paths):
        """
        Read config files.

        :param file_path: The file system path to the configuration file.

        :returns: boolean
        """
        for path in file_paths:
            try:
                with open(path) as fp:
                    _sections = yaml.load(fp)
                    if _sections is None:
                        _sections = {}

                self._sections = update(self._sections, _sections)