mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Cleanup FunctionWrapper
This commit is contained in:
parent
e55919b0d1
commit
d539380266
@ -42,6 +42,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
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user