Merge branch 'bug_713_fix_timerlist_sort'
[enigma2.git] / keymapparser.py
index 5023e94..0e544e9 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()