etingof / pysmi

SNMP MIB parser
http://snmplabs.com/pysmi/
BSD 2-Clause "Simplified" License
137 stars 52 forks source link

Introduce Jinja2 templates for code generation #41

Closed etingof closed 5 years ago

etingof commented 5 years ago

This change significantly refactors the way how code generation works. Previously, pysmi code generator has been responsible for producing a well-formed text document (e.g. JSON or pysnmp).

With this change, all code generations should be done through Jinja2 templates by rendering them in the context of the parsed MIB taking shape of the intermediate MIB representation which other parts of pysmi provide.

By way of moving pysnmp code generation to Jinja2 template, the Python code layout of pysnmp modules improved dramatically - it is just one little step from being PEP8-compliant.

This template-based pysnmp code generator drops some backward compatibility aids that keep Python MIB modules compatible with older pysnmp versions. Perhaps in the followup patch we should make the Python MIB module failing early and clearly on import when it's old pysnmp importing it.

codecov-io commented 5 years ago

Codecov Report

Merging #41 into master will increase coverage by 13.86%. The diff coverage is 86.18%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master      #41       +/-   ##
===========================================
+ Coverage   60.95%   74.81%   +13.86%     
===========================================
  Files          30       31        +1     
  Lines        2922     2351      -571     
===========================================
- Hits         1781     1759       -22     
+ Misses       1141      592      -549
Impacted Files Coverage Δ
pysmi/codegen/pysnmp.py 100% <100%> (+19.15%) :arrow_up:
pysmi/codegen/jsondoc.py 22.35% <50%> (+10.95%) :arrow_up:
pysmi/codegen/intermediate.py 85.81% <85.81%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update e11a5a0...7d8ee49. Read the comment docs.