A significant portion of the pysnirf2 code is generated dynamically from the SNIRF specification document maintained in the official repository.
This ensures easy maintenance of the project as the specification develops.
gen.py parses the spec document at the location defined as SPEC_SRC
in data.py.
gen.py then generates a dictionary of data which is combined with jinja2 template pysnirf2.jinja which metaprogrammatically generates the library source pysnirf2.py. Code is inserted between the start and end delimeters as specified. data.py should be updated and gen.py should be run when a new version of the SNIRF specification has been released.
- Ensure that data.py contains correct data to parse the latest spec. Make sure
SPEC_SRC
andVERSION
are up to date. - IMPORTANT! Back up or commit local changes to the code via git. The generation process may delete your changes.
- Using a Python > 3.6 environment equipped with gen/requirements.txt, run gen.py from the project root
- Test the resulting library