# Path: pybombs/utils/sysutils.py
# def which(program, env=None):
#     def is_exe(fpath):
# def dir_is_writable(dir_path):
# def mkdir_writable(dir_path, log=None):
# def mkdirp_writable(dir_path, log=None):
# def require_subdirs(base_path, subdirs, log=None):
# def write_file_in_subdir(base_path, file_path, content):
# def is_virtualenv(path):
# def get_interpreter_version():


import os
from collections import OrderedDict
from ruamel import yaml
from pybombs.utils import dict_merge
from pybombs.pb_exception import PBException
from pybombs.utils import sysutils
        touch_file(filename)
        with open(filename) as fn:
            try:
                # TODO: Recursively turn this into an OrderedDict, not just at
                # top level. In a nested dict, some key elements will still be
                # ruamel.ordereddict.
                self.data = OrderedDict(self.yaml.load(fn.read()) or {})
            except (IOError, OSError):
                self.data = OrderedDict()
            except Exception as e:
                raise PBException("Error loading {0}: {1}".format(filename, str(e)))
        assert isinstance(self.data, OrderedDict)

    def get(self, key=None, default=None):
        " Return the data from the config file as a dict "
        if key is None:
            return self.data
        if default is None:
            default = OrderedDict()
        # TODO Again, this is not recursive and sub-values may be non-vanilla
        # ordered dicts
        return OrderedDict(self.data.get(key, default))

    def save(self, newdata=None):
        " Write the contents of the data cache to the file. "
        if newdata is not None:
            assert isinstance(newdata, dict)
            self.data = newdata
        fpath = os.path.split(self._filename)[0]
        if len(fpath):

# Path: pybombs/utils/sysutils.py
# def which(program, env=None):
#     def is_exe(fpath):
# def dir_is_writable(dir_path):
# def mkdir_writable(dir_path, log=None):
# def mkdirp_writable(dir_path, log=None):
# def require_subdirs(base_path, subdirs, log=None):
# def write_file_in_subdir(base_path, file_path, content):
# def is_virtualenv(path):
# def get_interpreter_version():


# Path: pybombs/config_file.py
import os
from collections import OrderedDict
from ruamel import yaml
from pybombs.utils import dict_merge
from pybombs.pb_exception import PBException
from pybombs.utils import sysutils

        touch_file(filename)
        with open(filename) as fn:
            try:
                # TODO: Recursively turn this into an OrderedDict, not just at
                # top level. In a nested dict, some key elements will still be
                # ruamel.ordereddict.
                self.data = OrderedDict(self.yaml.load(fn.read()) or {})
            except (IOError, OSError):
                self.data = OrderedDict()
            except Exception as e:
                raise PBException("Error loading {0}: {1}".format(filename, str(e)))
        assert isinstance(self.data, OrderedDict)

    def get(self, key=None, default=None):
        " Return the data from the config file as a dict "
        if key is None:
            return self.data
        if default is None:
            default = OrderedDict()
        # TODO Again, this is not recursive and sub-values may be non-vanilla
        # ordered dicts
        return OrderedDict(self.data.get(key, default))

    def save(self, newdata=None):
        " Write the contents of the data cache to the file. "
        if newdata is not None:
            assert isinstance(newdata, dict)
            self.data = newdata
        fpath = os.path.split(self._filename)[0]
        if len(fpath):

            sysutils.mkdirp_writable(fpath)