This repository was archived by the owner on Feb 6, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcodeitInit.py
More file actions
59 lines (53 loc) · 2.33 KB
/
Copy pathcodeitInit.py
File metadata and controls
59 lines (53 loc) · 2.33 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
51
52
53
54
55
56
57
58
59
import os
from clint.textui import colored
from codeit.codeitMeta import template_cp, template_agg
def write_to_file(filename, text, contestName=None):
full_filename = os.path.join(os.getcwd(), filename)
if contestName is not None:
full_filename = os.path.join(os.getcwd(), contestName, filename)
with open(full_filename, 'w+') as f:
f.write(text)
def init(contestName,fileNames):
# create a directory with contest name
try:
print(colored.blue('Making files and folders for ' + colored.magenta(contestName)))
os.makedirs(os.path.join(os.getcwd(), contestName))
except OSError:
print(colored.red("Failed! This directory cannot be created as it exists."))
else:
print(colored.yellow('Directory is made'))
# create files for contest (should be 6 cpp files)
for files in range(len(fileNames)):
write_to_file(fileNames[files], template_cp(), contestName)
# create input file
write_to_file('input.txt', '', contestName)
write_to_file('output.txt', '', contestName)
print(colored.green('Files have been created. Happy Coding!'))
# For template 2
def init_agg(contestName, fileNames):
try:
print(colored.blue('Making files and folders for ' + colored.magenta(contestName)))
os.makedirs(os.path.join(os.getcwd(), contestName))
except OSError:
print(colored.red("Failed! This directory cannot be created as it exists."))
else:
print(colored.yellow('Directory is made'))
# create files for contest (should be 6 cpp files)
for files in range(len(fileNames)):
write_to_file(fileNames[files], template_agg(), contestName)
# create input file
write_to_file('input.txt', '', contestName)
write_to_file('output.txt', '', contestName)
print(colored.green('Files have been created. Happy Coding!'))
def create_only_files(contestName, fileNames):
try:
print(colored.blue('Making files for ' + colored.magenta(contestName)))
os.makedirs(os.path.join(os.getcwd(), contestName))
except OSError:
print(colored.red("Failed! This directory cannot be created as it exists."))
else:
print(colored.yellow('Directory is made'))
# create files for contest (should be 6 cpp files)
for files in range(len(fileNames)):
write_to_file(fileNames[files], template_agg(), contestName)
print(colored.green('Files have been created. Happy Coding!'))