From cc2ab2ab7b817e5c7aa80cd2a96355fd97a8f86f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Thu, 3 Nov 2022 23:18:19 +0100 Subject: keyboard.py namesto keyboard.txt --- gromka/keyboard.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 gromka/keyboard.py (limited to 'gromka/keyboard.py') diff --git a/gromka/keyboard.py b/gromka/keyboard.py new file mode 100755 index 0000000..14276cc --- /dev/null +++ b/gromka/keyboard.py @@ -0,0 +1,47 @@ +#!/usr/bin/python3 +import sys +try: + from bs4 import BeautifulSoup +except ModuleNotFoundError: + raise ModuleNotFoundError("beautifulsoup4 not found. emerge --ask dev-python/beautifulsoup4") + +if len(sys.argv) != 2: + raise ValueError("specify showfile in 1st argument") + +with open(sys.argv[1], "r") as f: + data = f.read(); + +show = BeautifulSoup(data, "xml") + +buttons = "F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 Pause Ins".split(" ") + "/ 1 2 3 4 5 6 7 8 9 0 ' +".split(" ") + "Q W E R T Z U I O P Š }".split(" ") + "A S D F G H J K L Č { Ž".split(" ") + "< Y X C V B N M , . -".split(" ") +keys = {} +for button in buttons: + keys[button] = "" + +for key in show.find_all("Key") + show.find_all("MultKey") + show.find_all("DivKey"): + keys[key.string] = "" + for parent in key.parents: + if parent.has_attr("Caption"): + keys[key.string] += parent["Caption"] + " (" + parent.name + ")" + break + +for key in keys: + print(key + ": " + keys[key]) + +print("\nmidi botex:") + +midi = [] +for x in range(0, 24): + midi.append("") + +for key in show.find_all("Input"): + if key.has_attr("Universe") and key["Universe"] == "0" and key.has_attr("Channel") and int(key["Channel"]) >= 198 and int(key["Channel"]) <= 198 + 24: + if midi[int(key["Channel"]) - 198] != "": + midi[int(key["Channel"]) - 198] += ", " + midi[int(key["Channel"]) - 198] += key.parent["Caption"] + " (" + key.parent.name + ")" + +for key in range(0, 24): + kje = " zgoraj" + if (key >= 12): + kje = " spodaj" + print(str(key % 12 + 1) + kje + ": " + midi[key]) -- cgit v1.2.3