Skip to content

Instantly share code, notes, and snippets.

@swarley
Created October 3, 2019 07:10
Show Gist options
  • Save swarley/0603fee172637c26200d033d2bae24f1 to your computer and use it in GitHub Desktop.
Save swarley/0603fee172637c26200d033d2bae24f1 to your computer and use it in GitHub Desktop.
QWERTY input to Left handed DVORAK
#! /usr/bin/python3
"""
Usage: ./qwerty_to_dvorak.py input.txt
OR cat input.txt | ./qwerty_to_dvorak.py
NOTE: This converts to LEFT HANDED DVORAK, not standard or right handed
"""
import sys
if len(sys.argv) == 2:
try:
text = open(sys.argv[1], 'r').read()
except:
print('Error opening', sys.argv[1])
raise SystemExit
else:
text = input()
qwerty = '`1234567890-=~!@#$%^&*()_+qwertyuiop[]\QWERTYUIOP{}|asdfghjkl;\'ASDFGHJKL:"zxcvbnm,./ZXCVBNM<>?'
dvorak = '`[]/pfmlj4321~{}?PFMLJ$#@!;qbyurso.65=\:QBYURSO>^%+|-kcdtheaz87_KCDTHEAZ*&\'xgvwni,09"XGVWNI<)('
translation = text.maketrans(dvorak, qwerty)
translated = text.translate(translation)
print(translated)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment