# Path: pybombs/pb_logging.py
# BOLD = str('\033[1m')
# TRACE = 1
# class ColoredConsoleHandler(logging.StreamHandler):
# class PBLogger(logging.getLoggerClass()):
#     def emit(self, record):
#     def __init__(self, *args, **kwargs):
#     def trace(self, *args, **kwargs):
# 
# 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


import os
from pybombs import pb_logging
from pybombs.pb_exception import PBException
from pybombs.config_file import PBConfigFile
# Boston, MA 02110-1301, USA.
#
"""
Inventory Manager
"""


class Inventory(object):
    """
    Inventory Manager.

    Every prefix has an inventory, a list of packages that are
    installed and in which state they current are.

    Except for save(), none of the methods actually writes to the
    inventory file.
    """
    _states = {
        'none':       (0,  'Package is not installed or fetched',),
        'fetched':    (10, 'Package source is in prefix, but not installed.',),
        'configured': (20, 'Package is downloaded and configured.',),
        'built':      (30, 'Package is compiled.',),
        'installed':  (40, 'Package is installed into current prefix.'),
    }

    def __init__(
            self,
            inventory_file=None,
        ):
        self._filename = inventory_file

# Path: pybombs/pb_logging.py
# BOLD = str('\033[1m')
# TRACE = 1
# class ColoredConsoleHandler(logging.StreamHandler):
# class PBLogger(logging.getLoggerClass()):
#     def emit(self, record):
#     def __init__(self, *args, **kwargs):
#     def trace(self, *args, **kwargs):
# 
# 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/inventory.py
import os
from pybombs import pb_logging
from pybombs.pb_exception import PBException
from pybombs.config_file import PBConfigFile

# Boston, MA 02110-1301, USA.
#
"""
Inventory Manager
"""


class Inventory(object):
    """
    Inventory Manager.

    Every prefix has an inventory, a list of packages that are
    installed and in which state they current are.

    Except for save(), none of the methods actually writes to the
    inventory file.
    """
    _states = {
        'none':       (0,  'Package is not installed or fetched',),
        'fetched':    (10, 'Package source is in prefix, but not installed.',),
        'configured': (20, 'Package is downloaded and configured.',),
        'built':      (30, 'Package is compiled.',),
        'installed':  (40, 'Package is installed into current prefix.'),
    }

    def __init__(
            self,
            inventory_file=None,
        ):
        self._filename = inventory_file

        self.log = pb_logging.logger.getChild("Inventory")