# Path: pybombs/config_file.py
# class PBConfigFile(object):
#     """
#     Abstraction layer for our config and other files
#     """
#     def __init__(self, filename):
#         # Store normalized path, in case someone chdirs after calling the ctor
#         self._filename = os.path.abspath(os.path.expanduser(os.path.normpath(filename)))
#         self.data = None
#         self.yaml = AbstractYaml()
#         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)
#         with open(self._filename, 'w') as fn:
#             self.yaml.dump(self.data, fn)
# 
#     def update(self, newdata):
#         " Overwrite the data with newdata recursively. Updates the file. "
#         self.data = dict_merge(self.data, newdata)
#         self.save()
#         return self.data


from pybombs.commands import CommandBase
from pybombs.config_file import PBConfigFile
            '-E', '--env', action='store_true', default=None,
            help="If specified, set an environment variable instead of the global configs",
        )

    def __init__(self, cmd, args):
        CommandBase.__init__(self,
            cmd, args,
            load_recipes=False,
            require_prefix=False,
        )
        # Figure out which config file to write to
        self.cfg_file = self.cfg.local_cfg
        prefix = self.cfg.get_active_prefix()
        if self.args.config_file is not None:
            self.cfg_file = self.args.config_file
        elif prefix.prefix_dir is not None and prefix.prefix_src == "cli":
            self.cfg_file = prefix.cfg_file
        self.log.info("Using config file: {0}".format(self.cfg_file))

    def run(self):
        " Go, go, go! "
        if self.args.package is not None or self.args.category is not None:
            return self._run_pkg_or_cat()
        if self.args.env is not None:
            return self._run_env()
        return self._run_config()

    def _run_config(self):
        " Handle `pybombs config' "
        if self.args.config_only:

# Path: pybombs/config_file.py
# class PBConfigFile(object):
#     """
#     Abstraction layer for our config and other files
#     """
#     def __init__(self, filename):
#         # Store normalized path, in case someone chdirs after calling the ctor
#         self._filename = os.path.abspath(os.path.expanduser(os.path.normpath(filename)))
#         self.data = None
#         self.yaml = AbstractYaml()
#         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)
#         with open(self._filename, 'w') as fn:
#             self.yaml.dump(self.data, fn)
# 
#     def update(self, newdata):
#         " Overwrite the data with newdata recursively. Updates the file. "
#         self.data = dict_merge(self.data, newdata)
#         self.save()
#         return self.data


# Path: pybombs/commands/config.py
from pybombs.commands import CommandBase
from pybombs.config_file import PBConfigFile

            '-E', '--env', action='store_true', default=None,
            help="If specified, set an environment variable instead of the global configs",
        )

    def __init__(self, cmd, args):
        CommandBase.__init__(self,
            cmd, args,
            load_recipes=False,
            require_prefix=False,
        )
        # Figure out which config file to write to
        self.cfg_file = self.cfg.local_cfg
        prefix = self.cfg.get_active_prefix()
        if self.args.config_file is not None:
            self.cfg_file = self.args.config_file
        elif prefix.prefix_dir is not None and prefix.prefix_src == "cli":
            self.cfg_file = prefix.cfg_file
        self.log.info("Using config file: {0}".format(self.cfg_file))

    def run(self):
        " Go, go, go! "
        if self.args.package is not None or self.args.category is not None:
            return self._run_pkg_or_cat()
        if self.args.env is not None:
            return self._run_env()
        return self._run_config()

    def _run_config(self):
        " Handle `pybombs config' "
        if self.args.config_only:

            cfg_data = PBConfigFile(self.cfg_file).get('config')