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 .. 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 = []