1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-18 12:06:04 +00:00

Update switch_lang.py

This commit is contained in:
RealOrge 2018-12-13 15:24:10 +02:00 committed by GitHub
parent 4a0a973e62
commit e7dede53a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@
from thefuck.utils import memoize, get_alias
target_layout = '''qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?'''
#any new keyboard layout must be appended
# any new keyboard layout must be appended
source_layouts = [u'''йцукенгшщзхъфывапролджэячсмитьбю.ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,''',
u'''йцукенгшщзхїфівапролджєячсмитьбю.ЙЦУКЕНГШЩЗХЇФІВАПРОЛДЖЄЯЧСМИТЬБЮ,''',
@ -35,22 +35,21 @@ def _switch(ch, layout):
def _switch_command(command, layout):
if (source_layouts.index(layout) == 3):# this is for the Greek keyboard
if (source_layouts.index(layout) == 3): # this is for the Greek keyboard
keyboardDic = {';': "q", 'ς': "w", 'ε': "e", 'ρ': "r", 'τ': "t", 'υ': "y", 'θ': "u", 'ι': "i", 'ο': "o", 'π': "p",
'[': "[", ']': "]", 'α': "a", 'σ': "s", 'δ': "d", 'φ': "f", 'γ': "g", 'η': "h", 'ξ': "j", 'κ': "k",
'λ': "l", ';': ";", '΄': "'", 'ζ': "z", 'χ': "x", 'ψ': "c", 'ω': "v", 'β': "b", 'ν': "n", 'μ': "m",
',': ",", '.': ".", '/': "/", ':': "Q", '΅': "W", 'Ε': "E", 'Ρ': "R", 'Τ': "T", 'Υ': "Y", 'Θ': "U",
'Ι': "I", 'Ο': "O", 'Π': "P", '{': "{", '}': "}", 'Α': "A", 'Σ': "S", 'Δ': "D", 'Φ': "F", 'Γ': "G",
'Η': "H", 'Ξ': "J", 'Κ': "K", 'Λ': "L", '¨': ":", '"': '"', 'Ζ': "Z", 'Χ': "X", 'Ψ': "C", 'Ω': "V",
'Β': "B", 'Ν': "N", 'Μ': "M", '<': "<", '>': ">", '?': "?", 'ά': "a", 'έ': "e", 'ύ': "y", 'ί': "i",
'ό': "o", 'ή': 'h', 'ώ': "v", 'Ά': "A", 'Έ': "E", 'Ύ': "Y", 'Ί': "I", 'Ό': "O", 'Ή': "H", 'Ώ': "V"}
'λ': "l", '΄': "'", 'ζ': "z", 'χ': "x", 'ψ': "c", 'ω': "v", 'β': "b", 'ν': "n", 'μ': "m", ',': ",",
'.': ".", '/': "/", ':': "Q", '΅': "W", 'Ε': "E", 'Ρ': "R", 'Τ': "T", 'Υ': "Y", 'Θ': "U", 'Ι': "I",
'Ο': "O", 'Π': "P", '{': "{", '}': "}", 'Α': "A", 'Σ': "S", 'Δ': "D", 'Φ': "F", 'Γ': "G", 'Η': "H",
'Ξ': "J", 'Κ': "K", 'Λ': "L", '¨': ":", '"': '"', 'Ζ': "Z", 'Χ': "X", 'Ψ': "C", 'Ω': "V", 'Β': "B",
'Ν': "N", 'Μ': "M", '<': "<", '>': ">", '?': "?", 'ά': "a", 'έ': "e", 'ύ': "y", 'ί': "i", 'ό': "o",
'ή': 'h', 'ώ': "v", 'Ά': "A", 'Έ': "E", 'Ύ': "Y", 'Ί': "I", 'Ό': "O", 'Ή': "H", 'Ώ': "V"}
newCommand = ""
for ch in command.script:
try:
newCommand += keyboardDic[ch]
except KeyError:# This character has no repressentation at the dictionary, so it is a symbol and therefore we can add him, now works only for spaces and for this symbol "-"
except KeyError: # This character has no repressentation at the dictionary, so it is a symbol and therefore we can add him, now works only for spaces and for this symbol "-"
newCommand += ch
return(newCommand)
return ''.join(_switch(ch, layout) for ch in command.script)