Simplify predicate finding logic YamlFSM

This commit is contained in:
Kristóf Tóth 2018-07-04 21:58:30 +02:00
parent 1beb419b09
commit c7ee97f0c6

View File

@ -42,9 +42,8 @@ class YamlFSM(FSMBase):
json_obj[key] = partial(run_command_async, json_obj[key])
def subscribe_and_remove_predicates(self, json_obj):
for key in json_obj:
if key == 'predicates':
for predicate in json_obj[key]:
if 'predicates' in json_obj:
for predicate in json_obj['predicates']:
self.subscribe_predicate(
json_obj['trigger'],
partial(
@ -52,6 +51,7 @@ class YamlFSM(FSMBase):
predicate
)
)
with suppress(KeyError):
json_obj.pop('predicates')