qwerty tool
This commit is contained in:
20
utils/.local/bin/qwerty
Executable file
20
utils/.local/bin/qwerty
Executable 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))
|
||||
Reference in New Issue
Block a user