From 77e9689a30c32a5f0251b02cf9b656898b1e8d71 Mon Sep 17 00:00:00 2001 From: Michael Trimarchi Date: Sun, 5 Mar 2023 13:59:52 +0100 Subject: [PATCH 1/2] python: Fix code generation python dreprecation yaml.load -> yaml.safe_load dict_keys -> access using a list Signed-off-by: Michael Trimarchi --- bin/mr_fsm_gen.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/mr_fsm_gen.py b/bin/mr_fsm_gen.py index 372736d..1ec572b 100755 --- a/bin/mr_fsm_gen.py +++ b/bin/mr_fsm_gen.py @@ -102,8 +102,8 @@ def terminate(self): class Transition(object): def __init__(self, transition_yml): - self.input = transition_yml.keys()[0] - self.next_state = transition_yml.values()[0] + self.input = list(transition_yml.keys())[0] + self.next_state = list(transition_yml.values())[0] def __str__(self): return "Transition={{ input={} next_state='{}' }}"\ @@ -154,7 +154,7 @@ def __init__(self, infile, outdir, default_implementations): def _parse_input_file(self): with open(self.input_file, 'r') as stream: - yml = yaml.load(stream) + yml = yaml.safe_load(stream) self._validate_fsm_yml(yml) name = yml["name"] states = [] From 8425c7af8b3b0c53e93046a9c8c50c5f25af1657 Mon Sep 17 00:00:00 2001 From: Michael Trimarchi Date: Sun, 5 Mar 2023 14:05:42 +0100 Subject: [PATCH 2/2] README: Fix compilation documentation Before compile the state machine files must be generated Signed-off-by: Michael Trimarchi --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3aea49f..7825199 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,9 @@ Have a look at [this great blog post](http://gameprogrammingpatterns.com/state.h After cloning the repository, run the following commands to build the project: ``` +# create the state machine files +./bin/mr_fsm_gen.py -i examples/simple_fsm.yml -o examples/ + mkdir build cd build cmake ..