mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Backport FunctionWrapper.__contains__
Otherwise `if 'config.get' in __salt__` fails becaues it tries to iterate over a list (starting with 0, 1, 2, etc)
This commit is contained in:
parent
f790f42ed6
commit
30595e3ff7
1 changed files with 12 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue