diff options
author | Santhosh Thottingal <santhosh.thottingal@gmail.com> | 2009-05-03 21:31:17 +0530 |
---|---|---|
committer | Santhosh Thottingal <santhosh.thottingal@gmail.com> | 2009-05-03 21:31:17 +0530 |
commit | 6d33918b6b8e90f80b3ea78b659fea155b2cb1e0 (patch) | |
tree | eab2fef7f698715a15f78bf416d35624f58c2375 /input-methods/ibus-sulekha/engine/keymap.py | |
parent | 7a81f78656d6a386231c0497819ace63a0079798 (diff) | |
download | Rachana.git-6d33918b6b8e90f80b3ea78b659fea155b2cb1e0.tar.gz Rachana.git-6d33918b6b8e90f80b3ea78b659fea155b2cb1e0.tar.xz Rachana.git-6d33918b6b8e90f80b3ea78b659fea155b2cb1e0.zip |
initial version of ibus-sulekha
Diffstat (limited to 'input-methods/ibus-sulekha/engine/keymap.py')
-rw-r--r-- | input-methods/ibus-sulekha/engine/keymap.py | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/input-methods/ibus-sulekha/engine/keymap.py b/input-methods/ibus-sulekha/engine/keymap.py new file mode 100644 index 0000000..8f049ca --- /dev/null +++ b/input-methods/ibus-sulekha/engine/keymap.py @@ -0,0 +1,65 @@ +# -*- coding: utf-8 -*- +# +# Sulekha +# +# Copyright (c) 2009 Santhosh Thottingal <santhosh.thiotttingal@gmail.com> +# +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place, Suite 330, +# Boston, MA 02111-1307 USA +import os +class Keymap: + def __init__(self, map="inscript_ml_IN"): + self. keymap_dict = self.load_key_map(map) + + def get_candidates(self,key): + if self. keymap_dict == None : + return None + if self. keymap_dict.has_key(key) : + value = self.keymap_dict[key] + candidate_list=value.split(":") + for candidate in candidate_list: + candidate = candidate.replace("\"",""); + candidate_list[candidate_list.index(candidate)] = candidate + return candidate_list + else : + return None + def load_key_map(self, map): + keymap_dict=dict() + try: + keymap_file = open("/usr/share/ibus-sulekha/engine/keymaps/"+map, 'r') + except: + print "Could not find keymaps/"+map + " file." + return None + while True: + line = keymap_file .readline() + if line == "": + break + line=line.strip() + try: + key = line.split("=")[0].strip() + value = line.split("=")[1].strip() + key = key.replace("\"","") + value = value.replace("\"","") + keymap_dict[key]=value + except: + continue + return keymap_dict +if __name__ == '__main__': + keymap= Keymap("swanalekha_ml_IN") + candidate_list= keymap.get_candidates("k") + for candidate in candidate_list: + print candidate + |