· 9 years ago · Dec 11, 2016, 12:38 AM
1Done by request, I have decided to make Hook compatible with the Python module! Please enjoy this, and do not forget to notify me any bugs or needed updates via. email!
2
3class Hook4Py():
4
5 """ Official Hook database of Python """
6
7 # Initiates package of module
8 def __init__(self):
9 self.table = []
10 self.row = 0
11 self.errors = 0
12
13 # Adds a new hook
14 def Add(self, name, args):
15 col = self.row
16 e = self.errors
17 self.row = col + 1
18
19 # Checks the table
20 for i in self.table:
21
22 # If name exists
23 if name in self.table[i]["name"]:
24 print("[ERROR] Failed to create hook. (Hook exists)")
25 self.errors = e + 1
26 break
27
28 # If no name given
29 if name:
30 try:
31 name = name
32 self.table[col] = {
33 "name": name,
34 "args": "|".join(args)
35 }
36 except:
37 print("[ERROR] Failed to create hook. (No name)")
38 self.errors = e + 1
39 break
40
41 # Removes the current hook
42 def Remove(self):
43 col = self.row
44 e = self.errors
45
46 # Checks the table
47 for i in self.table:
48
49 # If there is a hook
50 if not self.table[col]:
51
52 # If below zero
53 if col < 0:
54 self.row = 0
55 else:
56 self.table[i] = {}
57 self.errors = e - 1
58
59 # Gets the argument
60 def Argument(self):
61 col = self.row
62
63 # If there is a hook
64 if not self.table[col]:
65 return self.table[col]["args"]
66
67 # Gets amount of errors
68 def Errors(self):
69 e = self.errors
70
71 return e
72
73hook = Hook4Py()