Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import keymapviz.keyboards.kinesis
import keymapviz.keyboards.helix
import keymapviz.keyboards.mint60
import keymapviz.keyboards.kaishi65
KEYBOARDS = {
'crkbd': keymapviz.keyboards.crkbd,
'ergo42': keymapviz.keyboards.ergo42,
'ergodash': keymapviz.keyboards.ergodash,
'ergodox': keymapviz.keyboards.ergodox,
'ergodox_ez': keymapviz.keyboards.ergodox,
'fortitude60': keymapviz.keyboards.fortitude60,
'helix': keymapviz.keyboards.helix,
'kinesis': keymapviz.keyboards.kinesis,
'lets_split': keymapviz.keyboards.lets_split,
'mint60': keymapviz.keyboards.mint60,
'kaishi65': keymapviz.keyboards.kaishi65
}
class Keymapviz():
def __init__(self, keyboard, keymap_c, legends = None):
self.__keymap_c = keymap_c.read()
self.keyboard = KEYBOARDS[keyboard]
self.keymaps = self.__parse_keymap_c()
self.legends = legends if legends else {}
def __parse_keymap_c(self):
src = self.__keymap_c.split('\n')
src = [re.sub(r'\s*//.*$', '', _) for _ in src] # remove line comment