Merge branch 'bug_480_nfiflash' into experimental
[enigma2.git] / keymapparser.py
index 5023e944f7bf2204af0a5dc61d0598e7a0640581..0e544e94b5ef88fdf0f9c357c9e367a17e2003b0 100644 (file)
@@ -1,11 +1,18 @@
 import enigma
 import xml.etree.cElementTree
 
-from keyids import KEYIDS;
+from keyids import KEYIDS
 
 # these are only informational (for help)...
 from Tools.KeyBindings import addKeyBinding
 
+class KeymapError(Exception):
+    def __init__(self, message):
+        self.msg = message
+
+    def __str__(self):
+        return self.msg
+
 def parseKeys(context, filename, actionmap, device, keys):
        for x in keys.findall("key"):
                get_attr = x.attrib.get
@@ -29,12 +36,12 @@ def parseKeys(context, filename, actionmap, device, keys):
                        elif id[1] == 'd':
                                keyid = int(id[2:]) | 0x8000
                        else:
-                               raise "key id '" + str(id) + "' is neither hex nor dec"
+                               raise KeymapError("key id '" + str(id) + "' is neither hex nor dec")
                else:
                        try:
                                keyid = KEYIDS[id]
                        except:
-                               raise "key id '" + str(id) + "' is illegal"
+                               raise KeymapError("key id '" + str(id) + "' is illegal")
 #                              print context + "::" + mapto + " -> " + device + "." + hex(keyid)
                actionmap.bindKey(filename, device, keyid, flags, context, mapto)
                addKeyBinding(filename, keyid, context, mapto, flags)
@@ -48,7 +55,7 @@ def readKeymap(filename):
        try:
                dom = xml.etree.cElementTree.parse(source)
        except:
-               raise "keymap %s not well-formed." % filename
+               raise KeymapError("keymap %s not well-formed." % filename)
 
        keymap = dom.getroot()