-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (32 loc) · 1.02 KB
/
main.py
File metadata and controls
36 lines (32 loc) · 1.02 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
def main():
print("Welcome to OpenCV Installation by LearnOpenCV")
def writeBatchFile(batchFile):
newBatchFileName = batchFile[:-4]+"_modified.bat"
f_write = open(newBatchFileName,'w')
f_write.write("@echo off\n")
f_write.write("setlocal enabledelayedexpansion\n")
writeFlag=0
with open(batchFile,'r') as f:
for line in f.readlines():
if line[:3]=='::x':
writeFlag+=1
writeFlag=writeFlag%2
if writeFlag==0:
stringToWrite=line.rstrip()+"\n"
f_write.write(stringToWrite)
f_write.write("::====================================::\n")
f_write.write("echo @echo off>>runScript.bat\n")
f_write.write("echo setlocal enabledelayedexpansion >> runScript.bat\n")
writeFlag=0
with open(batchFile,'r') as f:
for line in f.readlines():
if line[:3] == '::/':
writeFlag+=1
writeFlag=writeFlag%2
if writeFlag==0:
stringToWrite="echo "+line.rstrip()+" >> runScript.bat\n"
f_write.write(stringToWrite)
f_write.close()
if __name__=="__main__":
cvVersionChoice=main()
writeBatchFile("installOpenCV.bat")