Merge pull request #23347 from basepi/salt-ssh.functionwrapper.contains.19114

[2014.7] Salt-SSH Backport FunctionWrapper.__contains__
This commit is contained in:
Mike Place 2015-05-05 08:13:20 -06:00
commit 4f760dd9cb

View File

@ -40,6 +40,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] # pylint: disable=W0104
return True
except KeyError:
return False
def __getitem__(self, cmd):
'''
Return the function call to simulate the salt local lookup system