# Path: servi/exceptions.py
# class MasterNotFound(Exception):
#     def __init__(self):
#         pass
# 
#     def __str__(self):
#         return (
#             '\n***** ERROR *****\n'
#             'Master directory not found at or above current directory.\n'
#             'Looking for: <master>/ServiFile.yml\n'
#             'Above cwd: {0}\n'
#             'Run "servi init <dirname>"\n'
#             '\n**Servi Aborting**'.format(os.getcwd()))
# 
# class ServiError(Exception):
#     # Expected errrors. Handle gracefully (ie: no stack dump)
#     def __init__(self, msg=None):
#         self.msg = msg
# 
#     def __str__(self):
#         return (
#             '\n***** ERROR *****\n'
#             '{0}\n'
#             '\n**Servi Aborting**'.format(self.msg))


import os
import os.path
import logging
import collections
import yaml
from logging import warning as warn
from jinja2 import Environment, DictLoader
from servi.exceptions import MasterNotFound, ServiError
    global_config = {}
    if not os.path.exists(SERVIFILE_GLOBAL_FULL):
        warn('No global servifile found in {0}'.format(SERVIFILE_GLOBAL_FULL))
    else:
        with open(SERVIFILE_GLOBAL_FULL) as f:
            servi_raw = f.read()
            global_config = process_config(servi_raw)

    if MASTER_DIR:
        user_config = getconfig(
            SERVIFILE, TEMPLATE, MASTER, TMPL_DIR_SITE, MASTER_DIR)
    else:
        warn('Getting config but MASTER_DIR is empty.')
        user_config = {}

    combined_config = deep_update(global_config, user_config)
    for k, v in combined_config.items():
        globals()[k] = v

    return global_config, user_config, combined_config


def find_master_dir(start_dir, fail_ok=False):
    """
    finds Servifile.yml at or above start_dir
    returns MasterNotFound or None (if fail_ok)
    """
    master_dir = find_ancestor_servifile(start_dir)
    if not master_dir:
        if not fail_ok:

# Path: servi/exceptions.py
# class MasterNotFound(Exception):
#     def __init__(self):
#         pass
# 
#     def __str__(self):
#         return (
#             '\n***** ERROR *****\n'
#             'Master directory not found at or above current directory.\n'
#             'Looking for: <master>/ServiFile.yml\n'
#             'Above cwd: {0}\n'
#             'Run "servi init <dirname>"\n'
#             '\n**Servi Aborting**'.format(os.getcwd()))
# 
# class ServiError(Exception):
#     # Expected errrors. Handle gracefully (ie: no stack dump)
#     def __init__(self, msg=None):
#         self.msg = msg
# 
#     def __str__(self):
#         return (
#             '\n***** ERROR *****\n'
#             '{0}\n'
#             '\n**Servi Aborting**'.format(self.msg))


# Path: servi/config.py
import os
import os.path
import logging
import collections
import yaml
from logging import warning as warn
from jinja2 import Environment, DictLoader
from servi.exceptions import MasterNotFound, ServiError

    global_config = {}
    if not os.path.exists(SERVIFILE_GLOBAL_FULL):
        warn('No global servifile found in {0}'.format(SERVIFILE_GLOBAL_FULL))
    else:
        with open(SERVIFILE_GLOBAL_FULL) as f:
            servi_raw = f.read()
            global_config = process_config(servi_raw)

    if MASTER_DIR:
        user_config = getconfig(
            SERVIFILE, TEMPLATE, MASTER, TMPL_DIR_SITE, MASTER_DIR)
    else:
        warn('Getting config but MASTER_DIR is empty.')
        user_config = {}

    combined_config = deep_update(global_config, user_config)
    for k, v in combined_config.items():
        globals()[k] = v

    return global_config, user_config, combined_config


def find_master_dir(start_dir, fail_ok=False):
    """
    finds Servifile.yml at or above start_dir
    returns MasterNotFound or None (if fail_ok)
    """
    master_dir = find_ancestor_servifile(start_dir)
    if not master_dir:
        if not fail_ok:

            raise MasterNotFound()