In my humble opinion it'd be better to make use of a proven templating engine (jinja2 for one, please see: https://jinja.palletsprojects.com/en/2.11.x/) for the code generation part of this project. This way the code will be more readable and maintainable in case of further changes.
I started a rework of the codegen part in 88a28ee8f1ecd93a613914c6388429b408dd0986
If you find that useful, please go ahead and adjust the remaining template code as necessary. I was not able to completely understand everything at the moment.
In my humble opinion it'd be better to make use of a proven templating engine (jinja2 for one, please see: https://jinja.palletsprojects.com/en/2.11.x/) for the code generation part of this project. This way the code will be more readable and maintainable in case of further changes.
I started a rework of the codegen part in 88a28ee8f1ecd93a613914c6388429b408dd0986 If you find that useful, please go ahead and adjust the remaining template code as necessary. I was not able to completely understand everything at the moment.