-
Notifications
You must be signed in to change notification settings - Fork 0
/
uglyparse.py
38 lines (34 loc) · 1.03 KB
/
uglyparse.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
import sys
from pynput import keyboard
from pynput.keyboard import Key, Controller
from time import sleep
keyboard=Controller()
# Change this for the computer's preference
# Swipe right when one of these preferences is met
preferences = ["sunflowers", "roses", "daisy"]
out_f = sys.argv[1]
# keys: class names values: scores
scores = {}
with open(out_f, "r") as f:
for l in f:
if "score" in l:
s = float(l.split("=")[1][:-2])
c = l.split(" (")[0]
scores[c] = s
pref_scores = [scores[pref] for pref in preferences]
for c, s in scores.items():
if c in preferences:
continue # skip
# check wether a non prefered class scores higher than any of the prefered classes
if all(s > s1 for s1 in pref_scores):
print("Swipe left!")
keyboard.press(Key.left)
keyboard.release(Key.left)
exit(0)
print("Swipe right!")
keyboard.press(Key.right)
keyboard.release(Key.right)
sleep(0.8)
# press esc to get out of menu
keyboard.press(Key.esc)
keyboard.release(Key.esc)