Guest User

Untitled

a guest
Oct 21st, 2019
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #! /usr/bin/python3
  2.  
  3. """
  4. Usage: ./qwerty_to_dvorak.py input.txt
  5. OR cat input.txt | ./qwerty_to_dvorak.py
  6.  
  7. NOTE: This converts to LEFT HANDED DVORAK, not standard or right handed
  8. """
  9.  
  10. import sys
  11.  
  12. if len(sys.argv) == 2:
  13. try:
  14. text = open(sys.argv[1], 'r').read()
  15. except:
  16. print('Error opening', sys.argv[1])
  17. raise SystemExit
  18. else:
  19. text = input()
  20.  
  21. qwerty = '`1234567890-=~!@#$%^&*()_+qwertyuiop[]\QWERTYUIOP{}|asdfghjkl;\'ASDFGHJKL:"zxcvbnm,./ZXCVBNM<>?'
  22. dvorak = '`[]/pfmlj4321~{}?PFMLJ$#@!;qbyurso.65=\:QBYURSO>^%+|-kcdtheaz87_KCDTHEAZ*&\'xgvwni,09"XGVWNI<)('
  23.  
  24. translation = text.maketrans(dvorak, qwerty)
  25. translated = text.translate(translation)
  26.  
  27. print(translated)
RAW Paste Data