forked from RV-AT/EVE_IDE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_sourcefile.py
66 lines (49 loc) · 2.09 KB
/
create_sourcefile.py
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
55
56
57
58
59
60
61
62
63
64
65
66
import os
import shutil
import time
configure_file = "configure.txt"
def read_line(name, li): # 读取指定文件指定行
with open(name, "r") as in_file:
num = 0
for line in in_file:
num += 1
if num == li:
return line
class move_source:
def __init__(self, project_path):
self.path = project_path
self.project_main_path = self.path + '/main.c'
self.project_source_path = self.path + '/source'
self.project_include_path = self.path + '/include'
self.time_now = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))
self.from_path = read_line(configure_file,5)[:-1]
self.source_path = self.from_path+'/source'
self.include_path = self.from_path + '/include'
self.pro_asm_path = self.path + '/main.S'
def create_empty(self):
with open(self.project_main_path,'w') as main:
main.write('//Created at '+self.time_now+'\n'+"//Eve ide ")
def create_amsonly(self):
with open(self.pro_asm_path,'w') as main:
main.write('//Created at '+self.time_now+'\n'+"//Eve ide ")
with open(self.path+"/a.txt","w")as a:
with open(self.path + "/main.bin", "w")as b:
pass
def create_with_source(self):#创建含有source的工程
'''
os.mkdir(self.project_source_path)
os.mkdir(self.project_include_path)
shutil.copytree(self.source_path,self.project_source_path)#复制source
shutil.copytree(self.include_path, self.project_include_path)#复制include
'''
'''
上面是一个一个
下面直接搬过来
下午来改
'''
shutil.copytree(self.from_path,self.path)
with open(self.path+'/Application/main.c','w+') as main:
main.write('//Created at '+self.time_now+'\n'+"//Eve ide for gd32vf103")
def create_with_main(self):#创建只有main的
with open(self.project_main_path,'w') as main:
main.write('//Created at '+self.time_now+'\n'+"//Eve ide for prv332")