Exemple #1
0
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())
Exemple #2
0
        # Output for stdout
        [print(_ + '\n') for _ in keymaps]
    else:
        # Output for file
        for i in range(len(keymaps)):
            f = output_filename.format(i)
            if os.path.exists(f):
                os.remove(f)

        for i, k in enumerate(keymaps):
            f = output_filename.format(i)
            with open(f, 'a') as file_:
                print(k, file=file_)


def output_keymap_c(output_filename, keymap_c):
    if os.path.exists(output_filename):
        os.rename(output_filename, output_filename + ".bac")
    with open(output_filename, 'w') as f:
        print(keymap_c, file=f, end='')


if __name__ == '__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())