-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcs-for-while.py
More file actions
30 lines (25 loc) · 875 Bytes
/
cs-for-while.py
File metadata and controls
30 lines (25 loc) · 875 Bytes
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
#! /bin/python
class bcolors :
FAIL = '\033[91m'
NORMAL = '\033[0m'
BOLD = '\033[1m'
import sys
if len(sys.argv) != 2:
sys.exit(2)
file = sys.argv[1]
with open(file) as f :
lines = f.readlines()
l_no = 1
found = 0;
for l in lines :
if 'for(' in l :
found = 1
sys.stderr.write(file + " : " + bcolors.FAIL + bcolors.BOLD + " ERROR" + bcolors.NORMAL + " 'for' in line " + str(l_no) + " is not followed by a space : 'for('\n")
if 'while(' in l :
found = 1
sys.stderr.write(file + " : " + bcolors.FAIL + bcolors.BOLD + " ERROR" + bcolors.NORMAL + " 'while' in line " + str(l_no) + " is not followed by a space : 'while('\n")
if 'if(' in l :
found = 1
sys.stderr.write(file + " : " + bcolors.FAIL + bcolors.BOLD + " ERROR" + bcolors.NORMAL + " 'if' in line " + str(l_no) + " is not followed by a space : 'if('\n")
l_no = l_no + 1
sys.exit(found)