-
Notifications
You must be signed in to change notification settings - Fork 0
/
keys_converter.py
53 lines (47 loc) · 1.76 KB
/
keys_converter.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
from selenium.webdriver.common.keys import Keys
class KeysConverter():
_keys_map = {
'9': {'keypad': Keys.NUMPAD9,
'occurence': None},
'0': {'keypad': Keys.NUMPAD0,
'occurence': None},
'1': {'keypad': Keys.NUMPAD1,
'occurence': None},
'2': {'keypad': Keys.NUMPAD2,
'occurence': None},
'3': {'keypad': Keys.NUMPAD3,
'occurence': None},
'4': {'keypad': Keys.NUMPAD4,
'occurence': None},
'5': {'keypad': Keys.NUMPAD5,
'occurence': None},
'6': {'keypad': Keys.NUMPAD6,
'occurence': None},
'7': {'keypad': Keys.NUMPAD7,
'occurence': None},
'8': {'keypad': Keys.NUMPAD8,
'occurence': None},
'+': {'keypad': Keys.ADD,
'occurence': None},
'-': {'keypad': Keys.SUBTRACT,
'occurence': None},
'*': {'keypad': Keys.MULTIPLY,
'occurence': None},
'/': {'keypad': Keys.DIVIDE,
'occurence': None},
'=': {'keypad': Keys.EQUALS,
'occurence': None}
}
def map_keys(self, element):
if element in self._keys_map:
return self._keys_map[element]['keypad']
def update_occurence(self, element: str, occurence: bool, **kwargs):
if not occurence:
self._keys_map[element]['occurence'] = False
else:
if self._keys_map[element]['occurence'] is None:
self._keys_map[element]['occurence'] = []
self._keys_map[element]['occurence'].append({
'attempted_position': kwargs['position'],
'is_correct': kwargs['is_correct']
})