-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasic_functions.py
More file actions
30 lines (29 loc) · 1.03 KB
/
basic_functions.py
File metadata and controls
30 lines (29 loc) · 1.03 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
#import cast.analysers.log as console
class Basic():
def __init__(self):
self.line_of_code = 0
self.line_of_comments = 0
self.no_of_blank_lines = 0
self.flag = 0
def cal_loc(self):
source_file = open("--Enter File Path--",'r')
for i in source_file:
if self.flag == 1:
if i.find('-->')==-1:
self.line_of_comments = self.line_of_comments + 1
else:
self.line_of_comments = self.line_of_comments + 1
self.flag = 0
else:
#print(len(i))
if len(i) == 1:
self.no_of_blank_lines =self.no_of_blank_lines + 1
elif i.find('<!--')!=-1:
self.line_of_comments = self.line_of_comments + 1
self.flag = 1
else:
self.line_of_code = self.line_of_code +1
#print(str(self.line_of_comments))
if __name__ == "__main__":
test= Basic()
test.cal_loc()