Skip to content

jasondoong/code_generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Introduction

This program is used to generate text from template. It will run python script between <py> </py> in template.

Steps

  1. Put your template in template.txt
  2. Put your data in data.py
  3. Execute generator.py

#Example template.txt:

public class <py>print class_name,</py> implements Serializable {

  private static final String docType = <py>print '"'+doc_type+'";'</py>
<py>
for field in field_list:
    print "  private " + field[0] + " " + field[1] + ';\n',
</py>

data.py:

class_name = 'AlEvent'
doc_type = 'alEvent'
field_list = [('int','eventId'),('String','stationName')]

Execution output:

@Entity
public class  AlEvent  implements Serializable {

  private static final String docType =  "alEvent";
  private int eventId;
  private String stationName;

About

a code_generator written by python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages