From c7ee97f0c689523b3bcdffc0953549c13f9825de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 4 Jul 2018 21:58:30 +0200 Subject: [PATCH] Simplify predicate finding logic YamlFSM --- lib/tfw/yaml_fsm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tfw/yaml_fsm.py b/lib/tfw/yaml_fsm.py index d868a70..1c2e1ec 100644 --- a/lib/tfw/yaml_fsm.py +++ b/lib/tfw/yaml_fsm.py @@ -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')