From 6d33918b6b8e90f80b3ea78b659fea155b2cb1e0 Mon Sep 17 00:00:00 2001 From: Santhosh Thottingal Date: Sun, 3 May 2009 21:31:17 +0530 Subject: initial version of ibus-sulekha --- input-methods/ibus-sulekha/engine/keymap.py | 65 +++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 input-methods/ibus-sulekha/engine/keymap.py (limited to 'input-methods/ibus-sulekha/engine/keymap.py') 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 +# +# +# 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 + -- cgit