-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsemicoloning.py
66 lines (43 loc) · 1.65 KB
/
semicoloning.py
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
import re
import sqlite3
import time
database = sqlite3.connect('semicolons.db')
user = database.cursor()
errors = 0
def replace_me(string):
global errors
if(string.find(';')==-1) and string!='' and string !='\n' :
raw_Expression = ["^(\w*)"]
regular_Expression= ''.join(raw_Expression)
check_String = re.findall('{0}'.format(regular_Expression) , string)
flag = fetch_Keyword(''.join(check_String))
if flag==1:
if string.find('\n')!=-1:
d = string.replace('\n','')
data = d+ ';'
errors+=1
else :
data = string +';'
# print(data)
return(data)
else :
data = string.replace('\n','')
return(data)
else:
return(string.replace('\n','') )
def fetch_Keyword(check_String) : #SUCCESS
flag = 0
user.execute("select * from semicolons")
data = user.fetchall()
user.execute("select second from semicolons")
data1 = user.fetchall()
for row in data:
if row[0] == check_String :
if row[1] == ';' :
flag =1
if flag == 1 :
return 1
else :
return 0
def error_count2() :
return(errors)