vmagamedov / grpclib

Pure-Python gRPC implementation for asyncio
http://grpclib.readthedocs.io
BSD 3-Clause "New" or "Revised" License
936 stars 92 forks source link

Use templating to generate code files #2

Closed claws closed 7 years ago

claws commented 7 years ago

Based on past experience I have found that generating source code files using templates is far more understandable and sustainable than manually managing structures and indenting as is done currently in the plugin/main.py.

I have modified the grplib package to use this approach, by using jinja2. If you are interested in seeing this let me know and I'll submit a pull request.

vmagamedov commented 7 years ago

Using templates is very tempting, but I'm intentionally not using them here, because it will add more dependencies. And another one concern against templates: it is possible but hard to manage whitespace and newlines, which is important in indentation-based code, plugin/main.py does this precisely.

I think that plugin/main.py will not require lots of modifications in the future, so easiness for grpclib maintainer should be less valuable than convenience for grpclib users. And I'm currently chosen convenience for grpclib users by not introducing extra dependencies (jinja2, markupsafe). Maybe plugin/main.py needs some refactoring)

claws commented 7 years ago

ok.