Refactoring of python module generator