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.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
src = [_.rstrip() for _ in src] # remove CRLF
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
src = [_.rstrip() for _ in src] # remove CRLF
src = ''.join(src)
import keymapviz.keyboards.lets_split
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')
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
def parse_arg():
keyboards = keymapviz.KEYBOARDS.keys()
types = list(TYPES.keys())
desc = 'keymap.c visualizer'
parser = argparse.ArgumentParser(description=desc,
epilog='Following keyboards are supported.\n * '+'\n * '.join(keyboards),
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-k', '--keyboard', type=str, choices=keyboards, help='keyboard of keymap.c', metavar='keyboards')
parser.add_argument('-o', '--output', type=str, help='output file name("{}" is replaced index)')
parser.add_argument('-r', '--replace', action='store_true', help='replace comment block including "[keymapviz]" with ascii art. (make *.bac)')
parser.add_argument('-t', '--type', dest='type_', type=str, choices=types, default=types[0], help='type of output(default:ascii)')
parser.add_argument('-v', '--version', action='version', version='%(prog)s {}'.format(VERSION))
parser.add_argument('keymap_c', type=argparse.FileType('r'), help='keymap.c file name')
arg = parser.parse_args()
import regex as re
import keymapviz.keyboards.crkbd
import keymapviz.keyboards.ergo42
import keymapviz.keyboards.ergodash
import keymapviz.keyboards.ergodox
import keymapviz.keyboards.fortitude60
import keymapviz.keyboards.lets_split
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()
def main():
arg = parse_arg()
kmvz = keymapviz.Keymapviz(arg.keyboard, arg.keymap_c, legends)
keymaps = getattr(kmvz, TYPES[arg.type_])()
output_keymaps(arg.output, keymaps)
if arg.replace:
output_keymap_c(arg.keymap_c.name, kmvz.keymap_c())
import keymapviz.keyboards.crkbd
import keymapviz.keyboards.ergo42
import keymapviz.keyboards.ergodash
import keymapviz.keyboards.ergodox
import keymapviz.keyboards.fortitude60
import keymapviz.keyboards.lets_split
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]
import keymapviz.keyboards.crkbd
import keymapviz.keyboards.ergo42
import keymapviz.keyboards.ergodash
import keymapviz.keyboards.ergodox
import keymapviz.keyboards.fortitude60
import keymapviz.keyboards.lets_split
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()
import keymapviz.keyboards.ergo42
import keymapviz.keyboards.ergodash
import keymapviz.keyboards.ergodox
import keymapviz.keyboards.fortitude60
import keymapviz.keyboards.lets_split
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 {}