|
|
@ -85,9 +85,8 @@ def parse(lines, indent):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Conditional(object):
|
|
|
|
class Conditional(object):
|
|
|
|
'''
|
|
|
|
"""Used in command modules to evaluate waitfor conditions
|
|
|
|
Used in command modules to evaluate waitfor conditions
|
|
|
|
"""
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OPERATORS = {
|
|
|
|
OPERATORS = {
|
|
|
|
'eq': ['eq', '=='],
|
|
|
|
'eq': ['eq', '=='],
|
|
|
@ -133,13 +132,20 @@ class Conditional(object):
|
|
|
|
raise AttributeError('unknown operator: %s' % oper)
|
|
|
|
raise AttributeError('unknown operator: %s' % oper)
|
|
|
|
|
|
|
|
|
|
|
|
def get_value(self, result):
|
|
|
|
def get_value(self, result):
|
|
|
|
for key in self.key.split('.'):
|
|
|
|
parts = re.split(r'\.(?=[^\]]*(?:\[|$))', self.key)
|
|
|
|
match = re.match(r'^(.+)\[(\d+)\]', key)
|
|
|
|
for part in parts:
|
|
|
|
|
|
|
|
match = re.findall(r'\[(\S+?)\]', part)
|
|
|
|
if match:
|
|
|
|
if match:
|
|
|
|
key, index = match.groups()
|
|
|
|
key = part[:part.find('[')]
|
|
|
|
result = result[key][int(index)]
|
|
|
|
result = result[key]
|
|
|
|
|
|
|
|
for m in match:
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
m = int(m)
|
|
|
|
|
|
|
|
except ValueError:
|
|
|
|
|
|
|
|
m = str(m)
|
|
|
|
|
|
|
|
result = result[m]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
result = result.get(key)
|
|
|
|
result = result.get(part)
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def number(self, value):
|
|
|
|
def number(self, value):
|
|
|
|