Skip to content

Instantly share code, notes, and snippets.

Created May 4, 2015 19:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/42203948dd06440a7c1c to your computer and use it in GitHub Desktop.
Save anonymous/42203948dd06440a7c1c to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# vim: set ft=python
"""
_modules.formula_dict
~~~~~~~~~~~~~~~
Description
This module contains the functions to make salt.utils.dictupdate.merge
available for use in our code. There a lazyloader bug in salt currently
so we need this function
https://github.com/saltstack/salt/issues/22444
"""
# Import python libs
from __future__ import absolute_import
# Import salt libs
from salt.utils import dictupdate
__virtualname__ = 'formula_dict'
#
# Classes and functions
#
def __virtual__():
"""
formula_dict.__virtual__
No deps. Load the module, if we add execution function to this modules
please add in logic to this function to make sure the module can be
loaded on minions
"""
return __virtualname__
def merge(dest, upd):
"""
formula_dict.merge
Allows deep merging of dicts so you don't accidentally overwrite stuff
"""
return dictupdate.update(dest, upd)
def get(source, key, default='', delimiter=':'):
return salt.utils.traverse_dict_and_list(source,
key,
default,
delimiter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment