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