# 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
            except ValueError:
                logger.warn("No such path {} in _custom_config_paths".format(path))
                
        else:
            return
        # Need to clear sections before reloading
        cls._instance._sections = cls._cls_dict()
        cls._instance.reload()

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

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

def get_config():
    return RatatoskConfigParser.instance()

def get_custom_config():
    """Get separate parser for custom config; else custom config
    parent_task setting will override config file settings"""
    return RatatoskCustomConfigParser.instance()

def setup_config(config_file=None, custom_config_file=None, **kwargs):
    """Helper function to setup config at startup"""
    if config_file:
        config = get_config()
        config.add_config_path(config_file)

# 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

            except ValueError:
                logger.warn("No such path {} in _custom_config_paths".format(path))
                
        else:
            return
        # Need to clear sections before reloading
        cls._instance._sections = cls._cls_dict()
        cls._instance.reload()

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

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

def get_config():
    return RatatoskConfigParser.instance()

def get_custom_config():
    """Get separate parser for custom config; else custom config
    parent_task setting will override config file settings"""
    return RatatoskCustomConfigParser.instance()

def setup_config(config_file=None, custom_config_file=None, **kwargs):
    """Helper function to setup config at startup"""
    if config_file:
        config = get_config()
        config.add_config_path(config_file)

        backend.__global_config__ = update(backend.__global_config__, vars(config)["_sections"])