Merge branch 'master' of git.opendreambox.org:/git/enigma2
[enigma2.git] / keymapparser.py
index 5023e944f7bf2204af0a5dc61d0598e7a0640581..63bca0f9a0f4aee02922a0b93f04fb7ac2f31f24 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.message = message
+
+    def __str__(self):
+        return self.message
+
 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()