qwerty tool

This commit is contained in:
2026-03-06 17:44:35 +08:00
parent e8247ba2ab
commit f7088631b2

20
utils/.local/bin/qwerty Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env python3
import sys
en = "qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?"
ru = "йцукенгшщзхъфывапролджэячсмитьбю.ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,"
def toggle(text):
if any('а' <= c <= 'я' or 'А' <= c <= 'Я' for c in text):
trans = str.maketrans(ru, en)
else:
trans = str.maketrans(en, ru)
return text.translate(trans)
if len(sys.argv) > 1:
input_text = " ".join(sys.argv[1:])
else:
input_text = sys.stdin.read().strip()
if input_text:
print(toggle(input_text))