-
Notifications
You must be signed in to change notification settings - Fork 3
/
Taboo.py
97 lines (73 loc) · 1.85 KB
/
Taboo.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
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
import DB
#For SU
"================================================="
def addTaboo(word):
try:
DB.tabooWord.update({
DB.tolower(word): DB.tolower(word)
})
return True
except Exception as e:
print("addTaboo()")
print(e)
def getTaboo():
try:
listoftaboo = DB.tabooWord.get()
result =[]
for key in listoftaboo:
result.append(listoftaboo[key])
return result
except Exception as e:
print("getTaboo()")
print(e)
def deleteTaboo(word):
try:
ref = DB.tabooWord
ref.child(DB.tolower(word)).delete()
return True
except Exception as e:
print("deleteTaboo()")
print(e)
def getSuggestedTaboo():
try:
ref = DB.root.child('Suggest_taboo').get()
taboo = []
if ref is not None:
for key in ref:
taboo.append(ref[key])
print(taboo)
return taboo
except Exception as e:
print("getSuggestedTaboo")
print(e)
"================================================"
def suggestTaboo(listofword):
try:
ref = DB.root.child('Suggest_taboo')
for word in listofword:
ref.update({
DB.tolower(word):DB.tolower(word)
})
except Exception as e:
print("suggestTaboo()")
print(e)
def deleteSuggestTaboo(word):
try:
ref = DB.suggestTaboo
ref.child(DB.tolower(word)).delete()
return True
except Exception as e:
print("deleteSuggestTaboo")
print(e)
def deleteAllTaboo():
try:
DB.tabooWord.delete()
except Exception as e:
print(e)
def deleteAllSuggest():
try:
DB.suggestTaboo.delete()
except Exception as e:
print(e)
if __name__ == '__main__':
deleteTaboo('7')