Skip to content
This repository was archived by the owner on Feb 6, 2022. It is now read-only.

Commit fb228a6

Browse files
committed
Refactor files and set for 0.0.2
1 parent 8c791df commit fb228a6

File tree

5 files changed

+62
-24
lines changed

5 files changed

+62
-24
lines changed

codeit/codeit.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
import os
44
from clint.textui import colored
55
from codeit.codeitHelp import help
6-
from codeit.codeitInit import init
7-
from codeit.codeitMeta import template_cp, get_filename
6+
from codeit.codeitInit import init, init_noerror
7+
from codeit.codeitMeta import template_cp, get_filename, get_fn_beginner
88

99
def main():
1010
if len(sys.argv) < 2:
1111
help()
1212

1313
else:
1414
countArg = 0
15+
1516
for arg in sys.argv:
1617
countArg+=1
1718

@@ -22,6 +23,19 @@ def main():
2223
init_single_file(f'{fileName}.cpp', template)
2324
print(colored.yellow(f'Created {fileName}.cpp'))
2425
break
26+
elif sys.argv[countArg] == '-b':
27+
if sys.argv[countArg+1] == '-ne':
28+
contestName = sys.argv[countArg+2]
29+
fileNames = get_fn_beginner()
30+
init_noerror(contestName, fileNames)
31+
else:
32+
contestName = sys.argv[countArg+1]
33+
fileNames = get_fn_beginner()
34+
init(contestName, fileNames)
35+
elif sys.argv[countArg] == '-ne':
36+
contestName = sys.argv[countArg+1]
37+
fileNames = get_filename()
38+
init_noerror(contestName, fileNames)
2539
else:
2640
contestName = sys.argv[countArg]
2741
fileNames = get_filename()

codeit/codeitHelp.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,22 @@
33
def help():
44
print('\n')
55

6-
print(colored.green("""
7-
.d88b .d88b. 888b. 8888 w w
8-
8P 8P Y8 8 8 8www w w8ww
9-
8b 8b d8 8 8 8 8 8
10-
`Y88P `Y88P' 888P' 8888 8 Y8P
11-
12-
"""))
13-
print('\n')
6+
print(colored.white(""" ██████╗ ██████╗ ██████╗ ███████╗██╗████████╗
7+
██╔════╝██╔═══██╗██╔══██╗██╔════╝██║╚══██╔══╝
8+
██║ ██║ ██║██║ ██║█████╗ ██║ ██║
9+
██║ ██║ ██║██║ ██║██╔══╝ ██║ ██║
10+
╚██████╗╚██████╔╝██████╔╝███████╗██║ ██║
11+
╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝
12+
"""))
1413

1514
print(colored.cyan("A CLI Script tool to help you initialize CPP files for any contest"))
1615
print('\nCommands:\n')
17-
print(colored.yellow("codeit -h -------------------- To display help menu"))
18-
print(colored.yellow("codeit -i <contest> ---------- To initialize a contest directory"))
19-
print(colored.yellow("codeit -i -n <file> ---------- To initialize only a single file"))
20-
print(colored.yellow("codeit -v -------------------- To print version number"))
21-
print(colored.yellow("codeit -p -------------------- To parse and compile the program"))
16+
print(colored.magenta("codemon <flags> <args>\n"))
17+
print(colored.red('Args list\n'))
18+
print(colored.yellow("-h \n" + colored.blue("To display help menu")))
19+
print(colored.yellow("-i <contest> \n" + colored.blue("To initialize a contest directory")))
20+
print(colored.yellow("-i -b <contest> \n" + colored.blue("To initialize a contest directory for practice and beginner level")))
21+
print(colored.yellow("-i <args> -ne <contest> \n" + colored.blue("To initialize a contest directory without error.txt file")))
22+
print(colored.yellow("-i -n <file> \n" + colored.blue("To initialize only a single file")))
23+
print(colored.yellow("-v \n" + colored.blue("To print version number")))
24+
print(colored.yellow("-p \n" + colored.blue("To parse and compile the program")))

codeit/codeitInit.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
from clint.textui import colored
3-
from codemon.CodemonMeta import template_cpp
3+
from codeit.codeitMeta import template_cp
44

55
def write_to_file(filename, text, contestName=None):
66
full_filename = os.path.join(os.getcwd(), filename)
@@ -15,14 +15,30 @@ def init(contestName,fileNames):
1515
print(colored.blue('Making files and folders for ' + colored.magenta(contestName)))
1616
os.makedirs(os.path.join(os.getcwd(), contestName))
1717
except OSError:
18-
print(colored.red("Failed! This directory cannot be created."))
18+
print(colored.red("Failed! This directory cannot be created as it exists."))
1919
else:
2020
print(colored.yellow('Directory is made'))
2121
# create files for contest (should be 6 cpp files)
2222
for files in range(len(fileNames)):
23-
write_to_file(fileNames[files], template_cpp(), contestName)
23+
write_to_file(fileNames[files], template_cp(), contestName)
2424
# create input file
2525
write_to_file('input.txt', '', contestName)
2626
write_to_file('output.txt', '', contestName)
2727
write_to_file('error.txt', '', contestName)
28-
print(colored.green('Files have been created. Happy Coding!'))
28+
print(colored.green('Files have been created. Happy Coding!'))
29+
30+
def init_noerror(contestName, fileNames):
31+
try:
32+
print(colored.blue('Making files and folders for ' + colored.magenta(contestName)))
33+
os.makedirs(os.path.join(os.getcwd(), contestName))
34+
except OSError:
35+
print(colored.red("Failed! This directory cannot be created as it exists."))
36+
else:
37+
print(colored.yellow('Directory is made'))
38+
# create files for contest (should be 6 cpp files)
39+
for files in range(len(fileNames)):
40+
write_to_file(fileNames[files], template_cp(), contestName)
41+
# create input file
42+
write_to_file('input.txt', '', contestName)
43+
write_to_file('output.txt', '', contestName)
44+
print(colored.green('Files have been created without error TXT file. Happy Coding!'))

codeit/codeitMeta.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,27 @@ def template_cp():
2020
freopen("input.txt", "r", stdin);
2121
freopen("error.txt", "w", stderr);
2222
freopen("output.txt", "w", stdout);
23+
//If you do not need error txt, remove it accordingly
2324
#endif
2425
2526
int t = 1;
2627
/*is Single Test case?*/
2728
cin >> t;
2829
while (t--) {
2930
//Code here
30-
cout << "\n";
31+
cout << endl;
3132
}
3233
33-
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
34+
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl; //Optional
3435
return 0;
3536
} """
3637

3738
return template
3839

3940
def get_filename():
40-
fileNames = ['A.cpp','B.cpp','C.cpp','D.cpp','E.cpp','F.cpp']
41-
return fileNames
41+
fileNames = ['A.cpp','B.cpp','C.cpp','D.cpp','E.cpp','F.cpp']
42+
return fileNames
43+
44+
def get_fn_beginner():
45+
fileNames = ['A.cpp','B.cpp','C.cpp']
46+
return fileNames

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='codeit',
5-
version='0.0.1',
5+
version='0.0.2',
66
author='Aadhitya A',
77
packages=find_packages(),
88
install_requires=[

0 commit comments

Comments
 (0)