-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathavigna.py
More file actions
263 lines (175 loc) · 8.82 KB
/
avigna.py
File metadata and controls
263 lines (175 loc) · 8.82 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#GUI FOR TAKING USER INPUT FOR THE STRINGS AND CORRECTING THE SPELLINGS
import sqlite3
import time
from tkinter import *
from tkinter import messagebox
from tkinter.filedialog import askopenfilename
from CHECK_SPELLINGS import finder
from comparison import check_here
from semicoloning import replace_me
spell_errors = 0
comp_errors = 0
semi_errors = 0
database = sqlite3.connect('clang.db')
user = database.cursor()
user.execute('CREATE TABLE IF NOT EXISTS keys(keyword TEXT, ending TEXT)')
#declaring the functions before hand to be implemented in the file
global fname
root= Tk()
def page() :
root.title("AVIGNA")
frame1 = Frame(root, cursor = 'dot')
frame1.grid(sticky=N+S+E+W)
frame1.rowconfigure(0,weight = 1)
frame1.columnconfigure(0,weight =1)
frame1.config(bg = 'LemonChiffon3')
#LABEL WIDGET
label_select = Label(frame1, text = "File Name Here:")
label_select.grid(row = 0 , column = 0 , padx =4 , pady = 4 )
label_select.config(font=('helvetica', 12, 'bold'),fg='red')
global entry_file
#ENTRY FILE WIDGET
entry_file= Entry(frame1)
entry_file.grid(row =1, column = 0)
entry_file.config(font=('helvetica', 12, 'bold'),fg='gray4', relief = RAISED, bd = 5)
fname = entry_file.get()
#GO BUTTON WIDGET
button_submit = Button(frame1 , text = " GO :",command =lambda : show_file(fname),padx = 10, pady = 10)
button_submit.grid(row = 1, column= 1, padx = 4, pady = 4,sticky=N+S+E+W)
button_submit.config(font=('helvetica', 10, 'bold'),bg='red2', fg='white', relief = RAISED)
#BROWSE FILES WIDGET
button_browse = Button(frame1, text = "Browse Files!",command = get_file)
button_browse.grid(row = 2 , column = 0 )
button_browse.config(font=('helvetica', 10, 'bold'),bg='red1', fg='white', relief = RAISED)
#ANALYSE FILES WIDGET
button_analyse = Button(frame1 , text = "ANALYSE",command = check_all)
button_analyse.grid(row = 3, column= 1, padx = 4, pady = 4)
button_analyse.config(font=('helvetica', 10, 'bold'),bg='red2', fg='white', relief = RAISED)
#LEVEL 2 WIDGET
button_analyse2 = Button(frame1 , text = "SAVE FILE",command = save_file)
button_analyse2.grid(row = 1, column=2 , padx = 4, pady = 4)
button_analyse2.config(font=('helvetica', 10, 'bold'),bg='red2', fg='white', relief = RAISED)
global text_show
#TEXT FIELD WIDGET
text_show = Text(frame1,undo =True, highlightcolor = 'gray')
text_show.grid( row =3, column = 0, padx = 10, pady = 10)
text_show.rowconfigure(0,weight = 1)
text_show.columnconfigure(0,weight =1)
text_show.config(font=('helvetica', 10, 'bold'),bg='azure', fg='black', relief = SUNKEN)
#BUTTON FOR SAVING REPORT
button_analyse3 = Button(frame1 , text = "SAVE REPORT",command = save_report)
button_analyse3.grid(row = 0, column=2, padx = 4, pady = 4)
button_analyse3.config(font=('helvetica', 10, 'bold'),bg='red', fg='white', relief = RAISED)
button_analyse4 = Button(frame1 , text = "CLEAR ALL >>",command = clear_function)
button_analyse4.grid(row = 2, column=2, padx = 4, pady = 4)
button_analyse4.config(font=('helvetica', 10, 'bold'),bg='red', fg='white', relief = RAISED)
#TEXT FIELD FOR OUTPUT
global text_show2
text_show2 = Text(frame1,undo =True)
text_show2.grid( row =3, column = 2, padx = 10, pady = 10)
text_show2.rowconfigure(0,weight = 1)
text_show2.columnconfigure(0,weight =1)
text_show2.config(font=('helvetica', 10, 'bold'),bg='red', fg='white', relief = SUNKEN)
root.mainloop()
def clear_function():
text_show.delete(1.0,END)
text_show2.delete(1.0,END)
messagebox.showinfo("Excuse me","Cleared !You are now good to go !")
def get_file() :
fname = askopenfilename(filetypes=(("TEXT files", "*.txt"),
("C files", "*.c;*.cpp"),
("All files", "*.*") ))
show_file(fname)
def show_file(fname):
if fname == '' :
messagebox.showinfo("Excuse Me!","I Was Expecting a File Name!")
else :
browse_file = open(fname,'r')
data = browse_file.readlines()
browse_file.close()
text_show.insert(INSERT, data)
def spell_check():
global spell_errors
print("ANALYSING MODULES")
new_data = []
data = text_show.get(1.0,END).strip().splitlines()
for i in range(0,len(data)):
print("REQUEST SENT ")
check_first = re.findall("^(\w*)",data[i])
passme = ''.join(check_first)
replace_text = finder(passme)
if replace_text !=passme:
spell_errors +=1
new_data.append(data[i].replace(passme,replace_text))
text_show.delete(1.0,END)
print("REQUEST RECIEVED")
for d in new_data:
text = d
text_show.insert(INSERT, d +'\n')
def check_comparison () :
print("SECOND STEP STARTED")
global comp_errors
new_data = []
data = text_show.get(1.0,END).strip().splitlines()
for i in range(0,len(data)):
passme = ''.join(data[i])
replace_text = check_here(passme)
if replace_text !=passme:
comp_errors +=1
new_data.append(data[i].replace(passme,replace_text))
text_show.delete(1.0,END)
for d in new_data:
text = d
text_show.insert(INSERT, d +'\n')
print("SECOND STEP IS COMPLETE")
def check_semicolons () :
global semi_errors
new_data = []
data = text_show.get(1.0,END).strip().splitlines(3)
for i in range(0,len(data)):
passme = ''.join(data[i])
replace_text = replace_me(passme)
p=''.join(replace_text)
if p.find(';')!=-1:
semi_errors +=1
new_data.append(data[i].replace(passme,replace_text))
print("LAST ANALYSIS OVER ")
text_show.delete(1.0,END)
for d in new_data:
text = d
text_show.insert(INSERT, d+ '\n')
def check_headers(data):
# new_data = []
# data = text_show.get(1.0,END).splitlines()
print(data[0])
for i in range(0,len(data)):
x = re.findall(('\#'),data[i])
passme = ''.join(x)
replace_text = finder(passme)
#for i in range(0,len(replace_text)):
# new_data.append(data[i].replace(passme,replace_text))
def save_file():
data = text_show.get(1.0,END).strip().splitlines()
print(data)
f = open('file.txt','w')
f.write(''.join(data))
f.close()
messagebox.showinfo("Excuse me","Saved with file name File!")
def save_report():
data = text_show2.get(1.0,END).strip().splitlines()
print(data)
f = open('report.txt','w')
f.write(''.join(data))
f.close()
messagebox.showinfo("Excuse me","Saved with file name Report!")
def check_all():
spell_check()
check_comparison()
check_semicolons()
text_show2.delete(1.0,END)
text_show2.insert(INSERT,'SPELLINGS ERRORS ARE :' +str(spell_errors)+'\n')
text_show2.insert(INSERT,'COMPARISON ERRORS ARE :' +str(comp_errors)+'\n')
text_show2.insert(INSERT,'CORRECTED SEMICOLONS ARE :' +str(semi_errors))
def main_function():
page()
main_function()