Commit da0f0309 by Anwar_N

handle configure parser exceptions

1 parent 089edca7
......@@ -79,24 +79,27 @@ class EngineSharadaBraille(IBus.Engine):
self.pressed_keys = u""
Config = configparser.ConfigParser()
if (Config.read("{}/isb.cfg".format(home_dir)) == []):
self.checked_languages = ["english-en","hindi-hi"]
self.simple_mode = 0
self.keycode_map = {33:"1",32:"2",31:"3",36:"4",37:"5",38:"6",44:"7",52:"8",30:"a",34:"c",35:"9",39:"0"}
self.key_to_switch_between_languages = 119
self.list_switch_key = 56
self.language_iter = 0
self.conventional_braille = False;
else:
try:
Config.read("{}/isb.cfg".format(home_dir))
self.checked_languages = Config.get('cfg',"checked_languages").split(",")
self.simple_mode = int(Config.get('cfg',"simple-mode"))
self.keycode_map = {}
for key,value in {"dot-1":"1","dot-2":"2","dot-3":"3","dot-4":"4","dot-5":"5","dot-6":"6","dot-7":"7","dot-8":"8","punctuation_key":"0","capitol_switch_key":"c","letter_deletion_key":"9","abbreviation_key":"a"}.items():
for key,value in {"dot-1":"1","dot-2":"2","dot-3":"3","dot-4":"4","dot-5":"5",
"dot-6":"6","dot-7":"7","dot-8":"8","punctuation_key":"0","capitol_switch_key":"c",
"letter_deletion_key":"9","abbreviation_key":"a"}.items():
self.keycode_map[int(Config.get('cfg',key))] = value
self.key_to_switch_between_languages = int(Config.get('cfg',"switch_between_languages"))
self.list_switch_key = int(Config.get('cfg',"list_switch_key"))
self.language_iter = int(Config.get('cfg',"default-language"))
self.conventional_braille = int(Config.get('cfg',"conventional-braille"))
except:
self.checked_languages = ["english-en","hindi-hi"]
self.simple_mode = 0
self.keycode_map = {33:"1",32:"2",31:"3",36:"4",37:"5",38:"6",44:"7",52:"8",30:"a",34:"c",35:"9",39:"0"}
self.key_to_switch_between_languages = 119
self.list_switch_key = 56
self.language_iter = 0
self.conventional_braille = False;
self.conventional_braille_dot_4 = False;
self.conventional_braille_dot_4_pass = False;
......
......@@ -45,7 +45,23 @@ class ibus_sharada_braille_preferences():
"dot-7":44,"dot-8":52,"punctuation_key":39,"capitol_switch_key":34,"letter_deletion_key":35,
"switch_between_languages":119,"list_switch_key":56,"abbreviation_key":30 }
if (self.config.read("{}/isb.cfg".format(home_dir)) == []):
try:
self.config.read("{}/isb.cfg".format(home_dir))
self.checked_languages = self.config.get('cfg',"checked_languages").split(",")
self.key_dict = {}
default_language = int(self.config.get('cfg',"default-language"))
for key in self.default_key_dict.keys():
self.key_dict[key] = int(self.config.get('cfg',key))
# The following are for a try only
self.config.get('cfg',"conventional-braille")
self.config.get('cfg',"simple-mode")
except:
# To avoid duplication of cfg section
try:
self.config.remove_section('cfg')
except:
pass
self.config.add_section('cfg')
self.checked_languages = ["english-en","hindi-hi","numerical-en"]
self.reset_keys_and_shorcuts(None,None)
......@@ -54,12 +70,6 @@ class ibus_sharada_braille_preferences():
self.config.set('cfg',"default-language",str(0))
default_language = 0;
self.key_dict = self.default_key_dict.copy()
else:
self.checked_languages = self.config.get('cfg',"checked_languages").split(",")
self.key_dict = {}
default_language = int(self.config.get('cfg',"default-language"))
for key in self.default_key_dict.keys():
self.key_dict[key] = int(self.config.get('cfg',key))
self.checked_languages_liststore = Gtk.ListStore(str)
for item in self.checked_languages:
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!