Trying to better follow DRY
authorEd Page <eopage@byu.net>
Sat, 10 Jul 2010 12:23:14 +0000 (07:23 -0500)
committerEd Page <eopage@byu.net>
Sat, 10 Jul 2010 12:25:20 +0000 (07:25 -0500)
17 files changed:
src/ejpi_qt.py
src/history.py
src/libraries/qtpieboard.py
src/plugin_utils.py
src/plugins/alphabet.map [deleted file]
src/plugins/alphabet.py
src/plugins/builtin_entry.ini [deleted file]
src/plugins/builtin_entry.map [deleted file]
src/plugins/builtin_entry.py [deleted file]
src/plugins/builtins.ini
src/plugins/builtins.map [deleted file]
src/plugins/builtins.py
src/plugins/computer.py
src/plugins/entry.ini [new file with mode: 0644]
src/plugins/entry.py [new file with mode: 0644]
src/plugins/trig.map [deleted file]
src/plugins/trig.py

index d853375..8e79de2 100755 (executable)
@@ -311,7 +311,7 @@ class MainWindow(object):
 
                self._constantPlugins = plugin_utils.ConstantPluginManager()
                self._constantPlugins.add_path(*self._plugin_search_paths)
-               for pluginName in ["Builtin", "Trigonometry", "Computer", "Alphabet"]:
+               for pluginName in ["Builtins", "Trigonometry", "Computer", "Alphabet"]:
                        try:
                                pluginId = self._constantPlugins.lookup_plugin(pluginName)
                                self._constantPlugins.enable_plugin(pluginId)
@@ -320,7 +320,7 @@ class MainWindow(object):
 
                self._operatorPlugins = plugin_utils.OperatorPluginManager()
                self._operatorPlugins.add_path(*self._plugin_search_paths)
-               for pluginName in ["Builtin", "Trigonometry", "Computer", "Alphabet"]:
+               for pluginName in ["Builtins", "Trigonometry", "Computer", "Alphabet"]:
                        try:
                                pluginId = self._operatorPlugins.lookup_plugin(pluginName)
                                self._operatorPlugins.enable_plugin(pluginId)
@@ -346,9 +346,9 @@ class MainWindow(object):
                self._handler.register_command_handler("clear", self._on_entry_clear)
 
                # Main keyboard
-               builtinKeyboardId = self._keyboardPlugins.lookup_plugin("Builtin")
+               builtinKeyboardId = self._keyboardPlugins.lookup_plugin("Builtins")
                self._keyboardPlugins.enable_plugin(builtinKeyboardId)
-               self._builtinPlugin = self._keyboardPlugins.keyboards["Builtin"].construct_keyboard()
+               self._builtinPlugin = self._keyboardPlugins.keyboards["Builtins"].construct_keyboard()
                self._builtinKeyboard = self._builtinPlugin.setup(self._history, self._handler)
 
                entryKeyboardId = self._keyboardPlugins.lookup_plugin("Entry")
index 9a0b47f..dcd04fa 100644 (file)
@@ -21,7 +21,7 @@ _VARIABLE_VALIDATION_RE = re.compile("^[a-zA-Z0-9]+$")
 def validate_variable_name(variableName):
        match = _VARIABLE_VALIDATION_RE.match(variableName)
        if match is None:
-               raise RuntimeError("Invalid characters")
+               raise RuntimeError("Invalid characters in '%s'" % variableName)
 
 
 def parse_number(userInput):
index bdd6e35..9e2cc1e 100755 (executable)
@@ -50,7 +50,7 @@ class PieKeyboard(object):
                "NORTH_EAST",
        ]
 
-       def __init__(self, rows, columns):
+       def __init__(self):
                self._layout = QtGui.QGridLayout()
 
                self.__cells = {}
index 26d00f0..32908e5 100644 (file)
@@ -36,14 +36,12 @@ class PieKeyboardPlugin(object):
        def setup(self, calcStack, boardHandler):
                self.__handler = boardHandler
 
-               with open(self.factory.mapFile, "r") as mapfile:
-                       boardTree = qtpieboard.parse_keyboard_data("\n".join(mapfile.readlines()))
+               boardTree = self.factory.map
 
-               rows, columns = boardTree["dimensions"]
                keyboardName = boardTree["name"]
                keyTree = boardTree["keys"]
 
-               keyboard = qtpieboard.PieKeyboard(rows, columns)
+               keyboard = qtpieboard.PieKeyboard()
                qtpieboard.load_keyboard(keyboardName, keyTree, keyboard, self.__handler, self.factory.iconPaths)
 
                for commandName, operator in self.factory.commands.iteritems():
@@ -64,11 +62,11 @@ class PieKeyboardPlugin(object):
 
 class PieKeyboardPluginFactory(object):
 
-       def __init__(self, pluginName, keyboardMapFile):
+       def __init__(self, pluginName, keyboardMap, iconPaths):
                self.name = pluginName
-               self.mapFile = keyboardMapFile
+               self.map = keyboardMap
                self.commands = {}
-               self.iconPaths = [os.path.join(os.path.dirname(keyboardMapFile), "images")]
+               self.iconPaths = iconPaths
 
        def register_operation(self, commandName, operator):
                self.commands[commandName] = operator
diff --git a/src/plugins/alphabet.map b/src/plugins/alphabet.map
deleted file mode 100644 (file)
index 1d1d7c2..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-{
-       "name": "Alphabet",
-       "dimensions": (3, 3),
-       "keys": {
-               (0, 0): {
-                       "CENTER": {"action": "e", "type": "text", "text": "E", },
-                       "SOUTH": {"action": "q", "type": "text", "text": "Q", },
-                       "EAST": {"action": "w", "type": "text", "text": "W", },
-                       "showAllSlices": True,
-               },
-               (0, 1): {
-                       "CENTER": {"action": "t", "type": "text", "text": "T", },
-                       "WEST": {"action": "r", "type": "text", "text": "R", },
-                       "EAST": {"action": "y", "type": "text", "text": "Y", },
-                       "SOUTH": {"action": "u", "type": "text", "text": "U", },
-                       "showAllSlices": True,
-               },
-               (0, 2): {
-                       "CENTER": {"action": "i", "type": "text", "text": "I", },
-                       "WEST": {"action": "o", "type": "text", "text": "O", },
-                       "SOUTH": {"action": "p", "type": "text", "text": "P", },
-                       "showAllSlices": True,
-               },
-               (1, 0): {
-                       "CENTER": {"action": "a", "type": "text", "text": "A", },
-                       "EAST": {"action": "s", "type": "text", "text": "S", },
-                       "showAllSlices": True,
-               },
-               (1, 1): {
-                       "CENTER": {"action": "h", "type": "text", "text": "H", },
-                       "WEST": {"action": "d", "type": "text", "text": "D", },
-                       "NORTH": {"action": "f", "type": "text", "text": "F", },
-                       "EAST": {"action": "g", "type": "text", "text": "G", },
-                       "SOUTH": {"action": "j", "type": "text", "text": "J", },
-                       "showAllSlices": True,
-               },
-               (1, 2): {
-                       "CENTER": {"action": "l", "type": "text", "text": "L", },
-                       "WEST": {"action": "k", "type": "text", "text": "K", },
-                       "showAllSlices": True,
-               },
-               (2, 0): {
-                       "CENTER": {"action": "c", "type": "text", "text": "C", },
-                       "NORTH": {"action": "z", "type": "text", "text": "Z", },
-                       "EAST": {"action": "x", "type": "text", "text": "X", },
-                       "showAllSlices": True,
-               },
-               (2, 1): {
-                       "CENTER": {"action": "b", "type": "text", "text": "B", },
-                       "NORTH": {"action": "v", "type": "text", "text": "V", },
-                       "showAllSlices": True,
-               },
-               (2, 2): {
-                       "CENTER": {"action": "n", "type": "text", "text": "N", },
-                       "NORTH_WEST": {"action": "m", "type": "text", "text": "M", },
-                       "showAllSlices": True,
-               },
-       },
-}
index 1977dba..359e1d6 100644 (file)
@@ -13,14 +13,69 @@ c b n
 from __future__ import division
 
 import os
-import operator
-
-import operation
 
 import sys
 sys.path.append("../")
 import plugin_utils
 
 
-_MAP_FILE_PATH = os.path.join(os.path.dirname(__file__), "alphabet.map")
-PLUGIN = plugin_utils.PieKeyboardPluginFactory("Alphabet", _MAP_FILE_PATH)
+_NAME = "Alphabet"
+_MAP = {
+       "name": _NAME,
+       "keys": {
+               (0, 0): {
+                       "CENTER": {"action": "e", "type": "text", "text": "E", },
+                       "SOUTH": {"action": "q", "type": "text", "text": "Q", },
+                       "EAST": {"action": "w", "type": "text", "text": "W", },
+                       "showAllSlices": True,
+               },
+               (0, 1): {
+                       "CENTER": {"action": "t", "type": "text", "text": "T", },
+                       "WEST": {"action": "r", "type": "text", "text": "R", },
+                       "EAST": {"action": "y", "type": "text", "text": "Y", },
+                       "SOUTH": {"action": "u", "type": "text", "text": "U", },
+                       "showAllSlices": True,
+               },
+               (0, 2): {
+                       "CENTER": {"action": "i", "type": "text", "text": "I", },
+                       "WEST": {"action": "o", "type": "text", "text": "O", },
+                       "SOUTH": {"action": "p", "type": "text", "text": "P", },
+                       "showAllSlices": True,
+               },
+               (1, 0): {
+                       "CENTER": {"action": "a", "type": "text", "text": "A", },
+                       "EAST": {"action": "s", "type": "text", "text": "S", },
+                       "showAllSlices": True,
+               },
+               (1, 1): {
+                       "CENTER": {"action": "h", "type": "text", "text": "H", },
+                       "WEST": {"action": "d", "type": "text", "text": "D", },
+                       "NORTH": {"action": "f", "type": "text", "text": "F", },
+                       "EAST": {"action": "g", "type": "text", "text": "G", },
+                       "SOUTH": {"action": "j", "type": "text", "text": "J", },
+                       "showAllSlices": True,
+               },
+               (1, 2): {
+                       "CENTER": {"action": "l", "type": "text", "text": "L", },
+                       "WEST": {"action": "k", "type": "text", "text": "K", },
+                       "showAllSlices": True,
+               },
+               (2, 0): {
+                       "CENTER": {"action": "c", "type": "text", "text": "C", },
+                       "NORTH": {"action": "z", "type": "text", "text": "Z", },
+                       "EAST": {"action": "x", "type": "text", "text": "X", },
+                       "showAllSlices": True,
+               },
+               (2, 1): {
+                       "CENTER": {"action": "b", "type": "text", "text": "B", },
+                       "NORTH": {"action": "v", "type": "text", "text": "V", },
+                       "showAllSlices": True,
+               },
+               (2, 2): {
+                       "CENTER": {"action": "n", "type": "text", "text": "N", },
+                       "NORTH_WEST": {"action": "m", "type": "text", "text": "M", },
+                       "showAllSlices": True,
+               },
+       },
+}
+PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, [])
diff --git a/src/plugins/builtin_entry.ini b/src/plugins/builtin_entry.ini
deleted file mode 100644 (file)
index cbbaa4d..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-[Operator]
-name=Entry
-version=0.1
-description=
-
-[Constants]
-name=Entry
-version=0.1
-description=
-
-[Keyboard]
-name=Entry
-version=0.1
-description=
diff --git a/src/plugins/builtin_entry.map b/src/plugins/builtin_entry.map
deleted file mode 100644 (file)
index 9f915df..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-{
-       "name": "Entry",
-       "dimensions": (1, 1),
-       "keys": {
-               (0, 0): {
-                       "CENTER": {"action": "[push]", "type": "image", "path": "newline.png", },
-                       "NORTH": {"action": "[unpush]", "type": "text", "text": "Undo", },
-                       "NORTH_WEST": {"action": "[clear]", "type": "image", "path": "clear.png", },
-                       "WEST": {"action": "[backspace]", "type": "image", "path": "backspace.png", },
-                       "showAllSlices": False,
-               },
-       },
-}
diff --git a/src/plugins/builtin_entry.py b/src/plugins/builtin_entry.py
deleted file mode 100644 (file)
index 7f32ddb..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-from __future__ import division
-
-import os
-
-import sys
-sys.path.append("../")
-import plugin_utils
-
-
-_NAME = "Entry"
-_MAP = {
-       "name": _NAME,
-       "keys": {
-               (0, 0): {
-                       "CENTER": {"action": "[push]", "type": "image", "path": "newline.png", },
-                       "NORTH": {"action": "[unpush]", "type": "text", "text": "Undo", },
-                       "NORTH_WEST": {"action": "[clear]", "type": "image", "path": "clear.png", },
-                       "WEST": {"action": "[backspace]", "type": "image", "path": "backspace.png", },
-                       "showAllSlices": False,
-               },
-       },
-}
-_ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
-PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, _ICON_PATH)
index 48acacd..3e74fd2 100644 (file)
@@ -1,14 +1,14 @@
 [Operator]
-name=Builtin
+name=Builtins
 version=0.1
 description=
 
 [Constants]
-name=Builtin
+name=Builtins
 version=0.1
 description=
 
 [Keyboard]
-name=Builtin
+name=Builtins
 version=0.1
 description=
diff --git a/src/plugins/builtins.map b/src/plugins/builtins.map
deleted file mode 100644 (file)
index f978384..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-{
-       "name": "Builtins",
-       "dimensions": (3, 3),
-       "keys": {
-               (0, 0): {
-                       "CENTER": {"action": "7", "type": "text", "text": "7", },
-                       "showAllSlices": True,
-               },
-               (0, 1): {
-                       "CENTER": {"action": "8", "type": "text", "text": "8", },
-                       "SOUTH": {"action": "[**]", "type": "text", "text": "**", },
-                       "EAST": {"action": "[sq]", "type": "text", "text": "sq", },
-                       "WEST": {"action": "[sqrt]", "type": "text", "text": "sqrt", },
-                       "showAllSlices": False,
-               },
-               (0, 2): {
-                       "CENTER": {"action": "9", "type": "text", "text": "9", },
-                       "showAllSlices": True,
-               },
-               (1, 0): {
-                       "CENTER": {"action": "4", "type": "text", "text": "4", },
-                       "showAllSlices": True,
-               },
-               (1, 1): {
-                       "CENTER": {"action": "5", "type": "text", "text": "5", },
-                       "EAST": {"action": "[+]", "type": "text", "text": "+", },
-                       "WEST": {"action": "[-]", "type": "text", "text": "-", },
-                       "NORTH": {"action": "[*]", "type": "text", "text": "*", },
-                       "SOUTH": {"action": "[/]", "type": "text", "text": "/", },
-                       "showAllSlices": True,
-               },
-               (1, 2): {
-                       "CENTER": {"action": "6", "type": "text", "text": "6", },
-                       "showAllSlices": True,
-               },
-               (2, 0): {
-                       "CENTER": {"action": "1", "type": "text", "text": "1", },
-                       "EAST": {"action": "0", "type": "text", "text": "0", },
-                       "showAllSlices": True,
-               },
-               (2, 1): {
-                       "CENTER": {"action": "2", "type": "text", "text": "2", },
-                       "EAST": {"action": "[abs]", "type": "text", "text": "abs", },
-                       "NORTH": {"action": ".", "type": "text", "text": ".", },
-                       "WEST": {"action": "[+-]", "type": "text", "text": "+/-", },
-                       "showAllSlices": True,
-               },
-               (2, 2): {
-                       "CENTER": {"action": "3", "type": "text", "text": "3", },
-                       "NORTH": {"action": "[!]", "type": "text", "text": "!", },
-                       "WEST": {"action": "j", "type": "text", "text": "j", },
-                       "showAllSlices": True,
-               },
-       },
-}
index f57520e..f19813f 100644 (file)
@@ -10,9 +10,62 @@ import sys
 sys.path.append("../")
 import plugin_utils
 
-
-_MAP_FILE_PATH = os.path.join(os.path.dirname(__file__), "builtins.map")
-PLUGIN = plugin_utils.PieKeyboardPluginFactory("Builtin", _MAP_FILE_PATH)
+_NAME = "Builtins"
+_MAP = {
+       "name": _NAME,
+       "keys": {
+               (0, 0): {
+                       "CENTER": {"action": "7", "type": "text", "text": "7", },
+                       "showAllSlices": True,
+               },
+               (0, 1): {
+                       "CENTER": {"action": "8", "type": "text", "text": "8", },
+                       "SOUTH": {"action": "[**]", "type": "text", "text": "**", },
+                       "EAST": {"action": "[sq]", "type": "text", "text": "sq", },
+                       "WEST": {"action": "[sqrt]", "type": "text", "text": "sqrt", },
+                       "showAllSlices": False,
+               },
+               (0, 2): {
+                       "CENTER": {"action": "9", "type": "text", "text": "9", },
+                       "showAllSlices": True,
+               },
+               (1, 0): {
+                       "CENTER": {"action": "4", "type": "text", "text": "4", },
+                       "showAllSlices": True,
+               },
+               (1, 1): {
+                       "CENTER": {"action": "5", "type": "text", "text": "5", },
+                       "EAST": {"action": "[+]", "type": "text", "text": "+", },
+                       "WEST": {"action": "[-]", "type": "text", "text": "-", },
+                       "NORTH": {"action": "[*]", "type": "text", "text": "*", },
+                       "SOUTH": {"action": "[/]", "type": "text", "text": "/", },
+                       "showAllSlices": True,
+               },
+               (1, 2): {
+                       "CENTER": {"action": "6", "type": "text", "text": "6", },
+                       "showAllSlices": True,
+               },
+               (2, 0): {
+                       "CENTER": {"action": "1", "type": "text", "text": "1", },
+                       "EAST": {"action": "0", "type": "text", "text": "0", },
+                       "showAllSlices": True,
+               },
+               (2, 1): {
+                       "CENTER": {"action": "2", "type": "text", "text": "2", },
+                       "EAST": {"action": "[abs]", "type": "text", "text": "abs", },
+                       "NORTH": {"action": ".", "type": "text", "text": ".", },
+                       "WEST": {"action": "[+-]", "type": "text", "text": "+/-", },
+                       "showAllSlices": True,
+               },
+               (2, 2): {
+                       "CENTER": {"action": "3", "type": "text", "text": "3", },
+                       "NORTH": {"action": "[!]", "type": "text", "text": "!", },
+                       "WEST": {"action": "j", "type": "text", "text": "j", },
+                       "showAllSlices": True,
+               },
+       },
+}
+PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, [])
 
 addition = operation.generate_function(operator.add, "+", operation.Function.REP_INFIX, 2)
 subtraction = operation.generate_function(operator.sub, "-", operation.Function.REP_INFIX, 2)
index 6f338c6..fb806a0 100644 (file)
@@ -11,8 +11,58 @@ sys.path.append("../")
 import plugin_utils
 
 
-_MAP_FILE_PATH = os.path.join(os.path.dirname(__file__), "computer.map")
-PLUGIN = plugin_utils.PieKeyboardPluginFactory("Computer", _MAP_FILE_PATH)
+_NAME = "Computer"
+_MAP = {
+       "name": _NAME,
+       "keys": {
+               (0, 0): {
+                       "CENTER": {"action": "[//]", "type": "text", "text": "//", },
+                       "showAllSlices": False,
+               },
+               (0, 1): {
+                       "CENTER": {"action": "[dec]", "type": "text", "text": "dec", },
+                       "showAllSlices": True,
+               },
+               (0, 2): {
+                       "CENTER": {"action": "[%]", "type": "text", "text": "%", },
+                       "showAllSlices": False,
+               },
+               (1, 0): {
+                       "CENTER": {"action": "[&]", "type": "text", "text": "and", },
+                       "showAllSlices": True,
+               },
+               (1, 1): {
+                       "CENTER": {"action": "[|]", "type": "text", "text": "or", },
+                       "NORTH": {"action": "[~]", "type": "text", "text": "not", },
+                       "showAllSlices": True,
+               },
+               (1, 2): {
+                       "CENTER": {"action": "[^]", "type": "text", "text": "xor", },
+                       "showAllSlices": True,
+               },
+               (2, 0): {
+                       "CENTER": {"action": "0x", "type": "text", "text": "0x", },
+                       "SOUTH": {"action": "[hex]", "type": "text", "text": "hex", },
+                       "NORTH_WEST": {"action": "a", "type": "text", "text": "A", },
+                       "WEST": {"action": "b", "type": "text", "text": "B", },
+                       "SOUTH_WEST": {"action": "c", "type": "text", "text": "C", },
+                       "NORTH_EAST": {"action": "d", "type": "text", "text": "D", },
+                       "EAST": {"action": "e", "type": "text", "text": "E", },
+                       "SOUTH_EAST": {"action": "f", "type": "text", "text": "F", },
+                       "showAllSlices": True,
+               },
+               (2, 1): {
+                       "CENTER": {"action": "0o", "type": "text", "text": "0o", },
+                       "SOUTH": {"action": "[oct]", "type": "text", "text": "oct", },
+                       "showAllSlices": True,
+               },
+               (2, 2): {
+                       "CENTER": {"action": "0b", "type": "text", "text": "0b", },
+                       "showAllSlices": True,
+               },
+       },
+}
+PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, [])
 
 hex = operation.change_base(16, "hex")
 oct = operation.change_base(8, "oct")
diff --git a/src/plugins/entry.ini b/src/plugins/entry.ini
new file mode 100644 (file)
index 0000000..cbbaa4d
--- /dev/null
@@ -0,0 +1,14 @@
+[Operator]
+name=Entry
+version=0.1
+description=
+
+[Constants]
+name=Entry
+version=0.1
+description=
+
+[Keyboard]
+name=Entry
+version=0.1
+description=
diff --git a/src/plugins/entry.py b/src/plugins/entry.py
new file mode 100644 (file)
index 0000000..7f32ddb
--- /dev/null
@@ -0,0 +1,24 @@
+from __future__ import division
+
+import os
+
+import sys
+sys.path.append("../")
+import plugin_utils
+
+
+_NAME = "Entry"
+_MAP = {
+       "name": _NAME,
+       "keys": {
+               (0, 0): {
+                       "CENTER": {"action": "[push]", "type": "image", "path": "newline.png", },
+                       "NORTH": {"action": "[unpush]", "type": "text", "text": "Undo", },
+                       "NORTH_WEST": {"action": "[clear]", "type": "image", "path": "clear.png", },
+                       "WEST": {"action": "[backspace]", "type": "image", "path": "backspace.png", },
+                       "showAllSlices": False,
+               },
+       },
+}
+_ICON_PATH = [os.path.join(os.path.dirname(__file__), "images")]
+PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, _ICON_PATH)
diff --git a/src/plugins/trig.map b/src/plugins/trig.map
deleted file mode 100644 (file)
index a524a88..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-{
-       "name": "Trigonometry",
-       "dimensions": (3, 3),
-       "keys": {
-               (0, 0): {
-                       "CENTER": {"action": "[sinh]", "type": "text", "text": "sinh", },
-                       "SOUTH": {"action": "[asinh]", "type": "text", "text": "asinh", },
-                       "showAllSlices": False,
-               },
-               (0, 1): {
-                       "CENTER": {"action": "[cosh]", "type": "text", "text": "cosh", },
-                       "SOUTH": {"action": "[acosh]", "type": "text", "text": "acosh", },
-                       "showAllSlices": False,
-               },
-               (0, 2): {
-                       "CENTER": {"action": "[tanh]", "type": "text", "text": "tanh", },
-                       "SOUTH": {"action": "[atanh]", "type": "text", "text": "atanh", },
-                       "showAllSlices": False,
-               },
-               (1, 0): {
-                       "CENTER": {"action": "[exp]", "type": "text", "text": "exp", },
-                       "NORTH": {"action": "[log]", "type": "text", "text": "log", },
-                       "showAllSlices": True,
-               },
-               (1, 1): {
-                       "CENTER": {"action": "pi", "type": "text", "text": "pi", },
-                       "NORTH": {"action": "e", "type": "text", "text": "e", },
-                       "showAllSlices": True,
-               },
-               (1, 2): {
-                       "CENTER": {"action": "[rad]", "type": "text", "text": "rad", },
-                       "NORTH": {"action": "[deg]", "type": "text", "text": "deg", },
-                       "showAllSlices": True,
-               },
-               (2, 0): {
-                       "CENTER": {"action": "[sin]", "type": "text", "text": "sin", },
-                       "SOUTH": {"action": "[asin]", "type": "text", "text": "asin", },
-                       "showAllSlices": False,
-               },
-               (2, 1): {
-                       "CENTER": {"action": "[cos]", "type": "text", "text": "cos", },
-                       "SOUTH": {"action": "[acos]", "type": "text", "text": "acos", },
-                       "showAllSlices": False,
-               },
-               (2, 2): {
-                       "CENTER": {"action": "[tan]", "type": "text", "text": "tan", },
-                       "SOUTH": {"action": "[atan]", "type": "text", "text": "atan", },
-                       "showAllSlices": False,
-               },
-       },
-}
index 6962794..dce5772 100644 (file)
@@ -1,7 +1,5 @@
 from __future__ import division
 
-import os
-import operator
 import math
 import cmath
 
@@ -12,8 +10,58 @@ sys.path.append("../")
 import plugin_utils
 
 
-_MAP_FILE_PATH = os.path.join(os.path.dirname(__file__), "trig.map")
-PLUGIN = plugin_utils.PieKeyboardPluginFactory("Trigonometry", _MAP_FILE_PATH)
+_NAME = "Trigonometry"
+_MAP = {
+       "name": _NAME,
+       "keys": {
+               (0, 0): {
+                       "CENTER": {"action": "[sinh]", "type": "text", "text": "sinh", },
+                       "SOUTH": {"action": "[asinh]", "type": "text", "text": "asinh", },
+                       "showAllSlices": False,
+               },
+               (0, 1): {
+                       "CENTER": {"action": "[cosh]", "type": "text", "text": "cosh", },
+                       "SOUTH": {"action": "[acosh]", "type": "text", "text": "acosh", },
+                       "showAllSlices": False,
+               },
+               (0, 2): {
+                       "CENTER": {"action": "[tanh]", "type": "text", "text": "tanh", },
+                       "SOUTH": {"action": "[atanh]", "type": "text", "text": "atanh", },
+                       "showAllSlices": False,
+               },
+               (1, 0): {
+                       "CENTER": {"action": "[exp]", "type": "text", "text": "exp", },
+                       "NORTH": {"action": "[log]", "type": "text", "text": "log", },
+                       "showAllSlices": True,
+               },
+               (1, 1): {
+                       "CENTER": {"action": "pi", "type": "text", "text": "pi", },
+                       "NORTH": {"action": "e", "type": "text", "text": "e", },
+                       "showAllSlices": True,
+               },
+               (1, 2): {
+                       "CENTER": {"action": "[rad]", "type": "text", "text": "rad", },
+                       "NORTH": {"action": "[deg]", "type": "text", "text": "deg", },
+                       "showAllSlices": True,
+               },
+               (2, 0): {
+                       "CENTER": {"action": "[sin]", "type": "text", "text": "sin", },
+                       "SOUTH": {"action": "[asin]", "type": "text", "text": "asin", },
+                       "showAllSlices": False,
+               },
+               (2, 1): {
+                       "CENTER": {"action": "[cos]", "type": "text", "text": "cos", },
+                       "SOUTH": {"action": "[acos]", "type": "text", "text": "acos", },
+                       "showAllSlices": False,
+               },
+               (2, 2): {
+                       "CENTER": {"action": "[tan]", "type": "text", "text": "tan", },
+                       "SOUTH": {"action": "[atan]", "type": "text", "text": "atan", },
+                       "showAllSlices": False,
+               },
+       },
+}
+PLUGIN = plugin_utils.PieKeyboardPluginFactory(_NAME, _MAP, [])
 
 pi = operation.Constant("pi", operation.Value(math.pi, operation.render_float_eng))
 e = operation.Constant("e", operation.Value(math.e, operation.render_float_eng))