From f7088631b2f7454e538983fb44d2710f4fbd8d9a Mon Sep 17 00:00:00 2001 From: Anthony Axenov Date: Fri, 6 Mar 2026 17:44:35 +0800 Subject: [PATCH] qwerty tool --- utils/.local/bin/qwerty | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 utils/.local/bin/qwerty diff --git a/utils/.local/bin/qwerty b/utils/.local/bin/qwerty new file mode 100755 index 0000000..9b365ec --- /dev/null +++ b/utils/.local/bin/qwerty @@ -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))