kenenet 1.2.5__py3-none-any.whl → 1.2.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kenenet/__init__.py +83 -5
- {kenenet-1.2.5.dist-info → kenenet-1.2.6.dist-info}/METADATA +1 -1
- kenenet-1.2.6.dist-info/RECORD +5 -0
- kenenet-1.2.5.dist-info/RECORD +0 -5
- {kenenet-1.2.5.dist-info → kenenet-1.2.6.dist-info}/WHEEL +0 -0
- {kenenet-1.2.5.dist-info → kenenet-1.2.6.dist-info}/top_level.txt +0 -0
kenenet/__init__.py
CHANGED
@@ -536,7 +536,7 @@ def get_focused_process_name(mute=False):
|
|
536
536
|
except psutil.NoSuchProcess:
|
537
537
|
return None
|
538
538
|
|
539
|
-
def
|
539
|
+
def rgb_at_coord(coord=None):
|
540
540
|
if coord is not None:
|
541
541
|
with mss.mss() as sct:
|
542
542
|
region = {"left": coord[0], "top": coord[1], "width": 1, "height": 1}
|
@@ -545,9 +545,9 @@ def coord_rgb(coord=None):
|
|
545
545
|
return rgb
|
546
546
|
else: return None
|
547
547
|
|
548
|
-
cr =
|
548
|
+
cr = rgb_at_coord
|
549
549
|
|
550
|
-
def
|
550
|
+
def rgb_is_at_coord(coord=None, rgb=None, range=1):
|
551
551
|
if not coord or not rgb:
|
552
552
|
return False
|
553
553
|
with mss.mss() as sct:
|
@@ -555,7 +555,7 @@ def rgb_at_coord(coord=None, rgb=None, range=1):
|
|
555
555
|
rgb_ac = sct.grab(region).pixel(0, 0)
|
556
556
|
return all(abs(a - b) <= range for a, b in zip(rgb_ac, rgb))
|
557
557
|
|
558
|
-
|
558
|
+
irac = rgb_is_at_coord
|
559
559
|
|
560
560
|
def if_condition(s):
|
561
561
|
e = s.strip()[3:] if s.strip().startswith("if ") else s
|
@@ -568,10 +568,88 @@ def if_condition(s):
|
|
568
568
|
code = ast.unparse(p)
|
569
569
|
val = eval(compile(ast.Expression(p), "<ast>", "eval"), ctx)
|
570
570
|
out.append(f"'{code}': {val}")
|
571
|
-
|
571
|
+
frame = inspect.currentframe().f_back
|
572
|
+
lineno = frame.f_lineno
|
573
|
+
quick_print(f"Overall: {str(full).upper()}, " + ", ".join(out), lineno)
|
572
574
|
|
573
575
|
if_cond = if_condition
|
574
576
|
|
577
|
+
def translate_morse_from_cursor(color_figuring=2.0, listen_duration=10.0, sample_interval=0.05, color_threshhold=15, mute=False):
|
578
|
+
_TARGET = zhmiscellany.misc.get_mouse_xy()
|
579
|
+
time.sleep(3)
|
580
|
+
found = []
|
581
|
+
t0 = time.time()
|
582
|
+
while time.time() - t0 < color_figuring:
|
583
|
+
c = rgb_at_coord(_TARGET)
|
584
|
+
if not any(math.dist(c, f) < color_threshhold for f in found):
|
585
|
+
found.append(c)
|
586
|
+
if len(found) >= 2:
|
587
|
+
break
|
588
|
+
time.sleep(sample_interval)
|
589
|
+
if len(found) >= 2:
|
590
|
+
c0, c1 = sorted(found, key=lambda c: (0.299*c[0] + 0.587*c[1] + 0.114*c[2]) / 255)
|
591
|
+
else:
|
592
|
+
c0, c1 = (found[0] if found else (0,0,0)), None
|
593
|
+
if not mute: quick_print(f'started recording, 2 colors are {c0, c1}')
|
594
|
+
raw, state = [], None
|
595
|
+
start = time.time()
|
596
|
+
while time.time() - start < listen_duration:
|
597
|
+
p = rgb_at_coord(_TARGET)
|
598
|
+
if c1 is not None:
|
599
|
+
s = '1' if math.dist(p, c1) < math.dist(p, c0) else '0'
|
600
|
+
else:
|
601
|
+
s = '0' if math.dist(p, c0) < color_threshhold else '1'
|
602
|
+
now = time.time()
|
603
|
+
if state is None:
|
604
|
+
state, ts = s, now
|
605
|
+
elif s != state:
|
606
|
+
raw.append((state, now - ts))
|
607
|
+
state, ts = s, now
|
608
|
+
time.sleep(max(0, sample_interval - (time.time() - now)))
|
609
|
+
if state:
|
610
|
+
raw.append((state, time.time() - ts))
|
611
|
+
|
612
|
+
ones = [d for s,d in raw if s == '1']
|
613
|
+
unit = min(ones) if ones else 0.15
|
614
|
+
pattern, cur = [], ''
|
615
|
+
MORSE = {
|
616
|
+
'.-': 'A', '-...': 'B', '-.-.': 'C', '-..': 'D', '.': 'E',
|
617
|
+
'..-.': 'F', '--.': 'G', '....': 'H', '..': 'I', '.---': 'J',
|
618
|
+
'-.-': 'K', '.-..': 'L', '--': 'M', '-.': 'N', '---': 'O',
|
619
|
+
'.--.': 'P', '--.-': 'Q', '.-.': 'R', '...': 'S', '-': 'T',
|
620
|
+
'..-': 'U', '...-': 'V', '.--': 'W', '-..-': 'X', '-.--': 'Y',
|
621
|
+
'--..': 'Z',
|
622
|
+
'-----': '0', '.----': '1', '..---': '2', '...--': '3', '....-': '4',
|
623
|
+
'.....': '5', '-....': '6', '--...': '7', '---..': '8', '----.': '9',
|
624
|
+
'.-.-.-': '.', '--..--': ',', '---...': ':', '..--..': '?',
|
625
|
+
'.----.': "'", '-.-.--': '!', '-..-.': '/', '.-..-.': '"',
|
626
|
+
'-....-': '-', '.-...': '&', '-.-.-.': ';', '...-.-': '$',
|
627
|
+
'.-.-.': '+', '.-..-': '_', '...---...': 'SOS'
|
628
|
+
}
|
629
|
+
|
630
|
+
for s, d in raw:
|
631
|
+
if s == '1':
|
632
|
+
cur += '.' if abs(d - unit) < unit*0.5 else '-'
|
633
|
+
else:
|
634
|
+
if cur:
|
635
|
+
if abs(d - unit) < unit*0.5:
|
636
|
+
pass
|
637
|
+
elif abs(d - 3*unit) < unit*0.5:
|
638
|
+
pattern.append(cur); cur = ''
|
639
|
+
elif abs(d - 7*unit) < unit*0.5:
|
640
|
+
pattern.append(cur); pattern.append(' '); cur = ''
|
641
|
+
else:
|
642
|
+
pattern.append(cur); cur = ''
|
643
|
+
else:
|
644
|
+
if abs(d - 7*unit) < unit*0.5:
|
645
|
+
pattern.append(' ')
|
646
|
+
if cur:
|
647
|
+
pattern.append(cur)
|
648
|
+
|
649
|
+
result = ''.join(' ' if e == ' ' else MORSE.get(e, '[?]') for e in pattern).strip()
|
650
|
+
if not mute: quick_print(result)
|
651
|
+
return result
|
652
|
+
|
575
653
|
class k:
|
576
654
|
pass
|
577
655
|
|
@@ -0,0 +1,5 @@
|
|
1
|
+
kenenet/__init__.py,sha256=rMDdcWY15HR7bpuHkrVkebqatdc0grJRQbq_JnSZDQo,26143
|
2
|
+
kenenet-1.2.6.dist-info/METADATA,sha256=ZhC9uvIq-kWv-gJFlEBSlPndw91OspZHpR2m8o06iAs,1693
|
3
|
+
kenenet-1.2.6.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
+
kenenet-1.2.6.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
+
kenenet-1.2.6.dist-info/RECORD,,
|
kenenet-1.2.5.dist-info/RECORD
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
kenenet/__init__.py,sha256=gojKDAkm-H7AFGGc8d4guZSM25oIHP-V5cLDMZYjOMo,22910
|
2
|
-
kenenet-1.2.5.dist-info/METADATA,sha256=_5pplHx9bNTlk36KJv2Ke4QXrTNPHAmOFmxNZpmdnA0,1693
|
3
|
-
kenenet-1.2.5.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
-
kenenet-1.2.5.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
-
kenenet-1.2.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|