Cleanup FunctionWrapper

This commit is contained in:
Thomas Jackson 2015-02-04 16:14:26 -08:00
parent 0f77253e27
commit dcf4550f4e
2 changed files with 15 additions and 4 deletions

View File

@ -45,6 +45,18 @@ class FunctionWrapper(object):
self.fsclient = fsclient
self.kwargs.update(kwargs)
def __contains__(self, key):
'''
We need to implement a __contains__ method, othwerwise when someone
does a contains comparison python assumes this is a sequence, and does
__getitem__ keys 0 and up until IndexError
'''
try:
self[key]
return True
except KeyError:
return False
def __getitem__(self, cmd):
'''
Return the function call to simulate the salt local lookup system

View File

@ -64,12 +64,11 @@ def render(yaml_data, saltenv='base', sls='', argline='', **kws):
if not data:
data = {}
else:
try:
if 'config.get' in __salt__:
if __salt__['config.get']('yaml_utf8', False):
data = _yaml_result_unicode_to_utf8(data)
except KeyError:
if __opts__.get('yaml_utf8'):
data = _yaml_result_unicode_to_utf8(data)
elif __opts__.get('yaml_utf8'):
data = _yaml_result_unicode_to_utf8(data)
log.debug('Results of YAML rendering: \n{0}'.format(data))
return data