1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-18 20:11:17 +00:00

Update switch_lang.py

This commit is contained in:
RealOrge 2018-12-13 14:25:15 +02:00 committed by GitHub
parent 66b13c53b3
commit 80d6b8da4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,11 +2,12 @@
from thefuck.utils import memoize, get_alias from thefuck.utils import memoize, get_alias
target_layout = '''qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?''' target_layout = '''qwertyuiop[]asdfghjkl;'zxcvbnm,./QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?'''
#any new keyboard layout must be appended
source_layouts = [u'''йцукенгшщзхъфывапролджэячсмитьбю.ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,''', source_layouts = [u'''йцукенгшщзхъфывапролджэячсмитьбю.ЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,''',
u'''йцукенгшщзхїфівапролджєячсмитьбю.ЙЦУКЕНГШЩЗХЇФІВАПРОЛДЖЄЯЧСМИТЬБЮ,''', u'''йцукенгшщзхїфівапролджєячсмитьбю.ЙЦУКЕНГШЩЗХЇФІВАПРОЛДЖЄЯЧСМИТЬБЮ,''',
u'''ضصثقفغعهخحجچشسیبلاتنمکگظطزرذدپو./ًٌٍَُِّْ][}{ؤئيإأآة»«:؛كٓژٰ‌ٔء><؟''', u'''ضصثقفغعهخحجچشسیبلاتنمکگظطزرذدپو./ًٌٍَُِّْ][}{ؤئيإأآة»«:؛كٓژٰ‌ٔء><؟''',
u''';ςερτυθιοπ[]ασδφγηξκλ;΄ζχψωβνμ,./:΅ΕΡΤΥΘΙΟΠ{}ΑΣΔΦΓΗΞΚΛ¨"ΖΧΨΩΒΝΜ<>?''', u''';ςερτυθιοπ[]ασδφγηξκλ΄ζχψωβνμ,./:΅ΕΡΤΥΘΙΟΠ{}ΑΣΔΦΓΗΞΚΛ¨"ΖΧΨΩΒΝΜ<>?''',
u'''/'קראטוןםפ][שדגכעיחלךף,זסבהנמצתץ.QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?'''] u'''/'קראטוןםפ][שדגכעיחלךף,זסבהנמצתץ.QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?''']
@ -17,7 +18,6 @@ def _get_matched_layout(command):
cmd = command.script.split(' ') cmd = command.script.split(' ')
for source_layout in source_layouts: for source_layout in source_layouts:
is_all_match = True is_all_match = True
for cmd_part in cmd: for cmd_part in cmd:
if not all([ch in source_layout or ch in '-_' for ch in cmd_part]): if not all([ch in source_layout or ch in '-_' for ch in cmd_part]):
is_all_match = False is_all_match = False
@ -35,6 +35,24 @@ def _switch(ch, layout):
def _switch_command(command, layout): def _switch_command(command, layout):
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"}
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 "-"
newCommand += ch
return(newCommand)
return ''.join(_switch(ch, layout) for ch in command.script) return ''.join(_switch(ch, layout) for ch in command.script)