Exemple #1
0
    def _combine(self, configs):
        """ Perform a prioritized recursive merge of serveral source files
        and returns a new dict.

        The merge order is based on the index of the list, meaning that
        elements at the end of the list will be merged last, and have greater
        precedence than elements at the beginning.  The result is then merged
        ontop of the defaults.

        :param configs: A list containing the yaml files to load.
        :return: dict
        """

        default = self._get_defaults()
        conf = anyconfig.to_container(default, ac_merge=MERGE_STRATEGY)
        conf.update(
            anyconfig.load(
                configs, ignore_missing=True, ac_merge=MERGE_STRATEGY))

        return m9dicts.convert_to(conf)
def convert_to(obj, ac_ordered=True, ac_namedtuple=False,
               ac_ntpl_cls_key=NTPL_CLS_KEY, **options):
    r"""
    Convert given `obj` :: m9dict object to a dict, dict or OrderedDict if
    ac_ordered == True, or a namedtuple if ac_namedtuple == True.

    .. seealso:: :func:`m9dicts.convert_to`

    :param obj: A m9dict object to convert to
    :param ac_ordered: OrderedDict will be chosen if True
    :param ac_namedtuple: A namedtuple object will be chosen if True
    :param ac_ntpl_cls_key: The name of namedtuple object
    :param options:
        Optional keyword arguments for m9dicts.convert_to, will be converted to
        the above ac_\* options respectively as needed.
    """
    opts = dict(ordered=ac_ordered, to_namedtuple=ac_namedtuple,
                _ntpl_cls_key=ac_ntpl_cls_key)

    return m9dicts.convert_to(obj, **opts)
Exemple #3
0
    def _combine(self, configs):
        """ Perform a prioritized recursive merge of serveral source files
        and returns a new dict.

        The merge order is based on the index of the list, meaning that
        elements at the end of the list will be merged last, and have greater
        precedence than elements at the beginning.  The result is then merged
        ontop of the defaults.

        :param configs: A list containing the yaml files to load.
        :return: dict
        """

        default = self._get_defaults()
        conf = anyconfig.to_container(default, ac_merge=MERGE_STRATEGY)
        conf.update(
            anyconfig.load(
                configs, ignore_missing=True, ac_merge=MERGE_STRATEGY))

        return m9dicts.convert_to(conf)
Exemple #4
0
    def _write_vagrant_state_file(self):
        driver_config = convert_to(self.molecule.config.config['vagrant'])
        driver_config['current_platform'] = self.platform
        driver_config['current_provider'] = self.provider

        self.molecule.state.change_state('driver_config', driver_config)
    def _write_vagrant_state_file(self):
        driver_config = convert_to(self.molecule.config.config['vagrant'])
        driver_config['current_platform'] = self.platform
        driver_config['current_provider'] = self.provider

        self.molecule.state.change_state('driver_config', driver_config)