#27 refactoring function for generating rest.py and edit.py