-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.py
More file actions
54 lines (44 loc) · 1012 Bytes
/
Copy pathcommon.py
File metadata and controls
54 lines (44 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env python
# coding:utf8
#
# Author: Lichain.Yu (lichain) <airy.cloud@gmail.com>
# Copyright: Lichain.Yu (lichain) <airy.cloud@gmail.com>
# License: MIT
#
##read input data
volatile_settings = {
'file_name':'test.cs',
'type':'1',
'class_name':'sp_input'
}
data_member =[
'test1',
'test2',
'test3',
'test4'
]
data =""
file = open('template.txt','r')
while True:
line = file.readline()
if(len(line)==0):
break
if('##file_name##' in line):
data += line.replace('##file_name##',volatile_settings['class_name'])
elif('##data_member##' in line):
context =""
for s in data_member:
context += "\tpublic string " + s + " {get; set;}\n"
data += line.replace('##data_member##',context)
else:
data += line
#break;
# data += line
file.close()
print data
fout = open("test.cs", "w")
fout.write(data)
fout.close()
#print volatile_settings['file_name']
#for s in data_member:
#print s