3 from pprint import pprint as pp
5 layers = dict(enumerate(['_QWERTY', '_LOWER', '_RAISE', '_MOVEMENT', '_NUMPAD']))
6 key_names = {('MO(%d)' % i): layers.get(i).strip('_') for i in layers.keys()}
9 "<i class='fa fa-fast-forward'></i>": "next",
10 "<i class='fa fa-volume-down'></i>": "vol-",
11 "<i class='fa fa-volume-up'></i>": "vol+",
12 "<i class='fa fa-play'></i>": "play",
15 d = json.load(open('layouts/community/ortho_4x12/guidoism/guidoism.json'))
17 def grouper(iterable, n):
18 args = [iter(iterable)] * n
19 return itertools.zip_longest(*args, fillvalue='')
22 return [a for a in s if a]
25 return [a.center(n*2+1 if len(s) == 11 and i == 5 else n) for i, a in enumerate(s)]
28 return [key_names.get(a, a) for a in s]
31 n = max(len(s) for s in l)
32 rows = [', '.join(replace(truthy(row))) for row in grouper(l, 12)]
33 return '[%s] = %s(\n%s)' % (layers[i], d['layout'], ',\n'.join(rows))
35 print(',\n\n'.join(layer(i, l) for i, l in enumerate(d['layers'])))
37 def surround(s, a, b, c):
38 return a + b.join(s) + c
40 def pattern(cell, table):
41 return ['─'*cell for i in range(table)]
43 keys = json.load(open('layouts/community/ortho_4x12/guidoism/keys.json'))
47 s = [keys.get(a, a) for a in s]
48 return [unicodes.get(a, a) for a in s]
49 n = max(len(s) for s in l)
50 return [surround(just(replace(truthy(row)), 5), '│', '│', '│') for row in grouper(l, 12)]
52 for i, l in enumerate(d['layers']):
53 print(surround(pattern(5, 12), '┌', '┬', '┐'))
54 for n, row in enumerate(layer2(i, l)):
57 print(surround(pattern(5, 12), '├', '┼', '┤'))
59 print(surround(pattern(5, 12), '└', '┴', '┘'))