-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.py
68 lines (58 loc) · 1.64 KB
/
make.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
67
68
import shutil
import os
class TestMaker:
current_dir = os.getcwd()
test_path = os.path.join(current_dir, 'Test')
def exist_folder(self):
'''
Check Test folder is Exist.
'''
if os.path.exists(TestMaker.test_path):
raise FileExistsError
def makeinput(self,num):
'''
Make inpput testcase file
'''
full_path = os.path.join(TestMaker.test_path, 'in')
if not os.path.exists(full_path):
os.makedirs(full_path)
os.chdir(full_path)
with open('input%d.txt' % (num), 'w') as f:
pass
f.close()
def makeoutput(self,num):
'''
Make output testcase file
'''
full_path = os.path.join(TestMaker.test_path, 'out')
if not os.path.exists(full_path):
os.makedirs(full_path)
os.chdir(full_path)
with open('output%d.txt' % (num), 'w') as f:
pass
f.close()
def main():
'''
This is the main of our program
'''
test=TestMaker()
try:
test.exist_folder()
num = int(input('How many test case do you need? \n'))
for i in range(1, num+1):
test.makeinput(i)
test.makeoutput(i)
print('Done')
command=input('Enter to Continue :)')
if command=='\n':
exit()
except FileExistsError:
print('File or Directory Exist, Do you wanna delete it? [y/n]')
if input() == 'y':
shutil.rmtree('Test')
main()
else:
exit()
if __name__ == '__main__':
main()
# Mohammad YousefiPour - Github.com/myp79