-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilereadtest.py
More file actions
51 lines (44 loc) · 1.25 KB
/
filereadtest.py
File metadata and controls
51 lines (44 loc) · 1.25 KB
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
#read text
items=['EVENT_NONE']
with open('C:/Users/tfgui/Documents/PythonTest/ClientEvents.txt','r') as f:
lines=f.readlines()
for i in lines:
temp=i.strip()
if len(temp)==0:
continue
if temp[0:2]=='//':
continue
items.append(temp)
print(items)
def writeline(file, line, end=''):
#file.write(line)
#file.write(end)
#file.write('\n')
file.write(line+end+'\n')
#save .h
path='C:/Users/tfgui/Documents/Arduino/fsxconnect/ClientEvents.h'
with open(path, 'w') as f:
#f.write('enum CLIENT_EVENTS {')
#f.write('NONE,')
writeline(f, 'enum CLIENT_EVENTS')
writeline(f, '{')
for i in items:
writeline(f, i, end=',')
writeline(f, '};')
#save .cs
path='C:/Users/tfgui/source/repos/FSXConnectCS/FSXConnectCS/ClientEvents.cs'
with open(path, 'w') as f:
#f.write('enum CLIENT_EVENTS {')
#f.write('NONE,')
writeline(f, 'enum CLIENT_EVENTS')
writeline(f, '{')
for i in items:
writeline(f, i, end=',')
writeline(f, '};')
#save .py
path='C:/Users/tfgui/Documents/PythonTest/FSXConnectPi/ClientEvents.py'
with open(path, 'w') as f:
value=0
for i in items:
writeline(f, i, end='=%d'%value)
value+=1