File: 2_genoptions_layout.py

package info (click to toggle)
mysql-workbench 6.2.3%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 102,612 kB
  • ctags: 84,593
  • sloc: ansic: 804,682; cpp: 438,759; yacc: 59,129; python: 54,293; xml: 48,851; sql: 5,512; objc: 1,414; makefile: 505; sh: 455; java: 237; ruby: 6; perl: 5; php: 1
file content (32 lines) | stat: -rw-r--r-- 841 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

from variable_groups import variable_groups


tabs = {}

for name, groups in variable_groups:
    for group in groups:
        tab, section = group.split("/", 1)
        if tab not in tabs:
            tabs[tab] = {}
        tabc = tabs[tab]
        if section not in tabc:
            tabc[section] = []
        tabc[section].append(name)

def mycmp(a, b):
    order = ['General', 'Logging', 'InnoDB', 'Networking', 'Security', 'Replication', 'MyISAM', 'Advanced']
    if a[0] in order and b[0] in order:
        return order.index(a[0]) - order.index(b[0])
    return cmp(a[0], b[0])

def mysort(l):
    l.sort(mycmp)
    return l

out = open("options_layout.py", "w+")
out.write("layout = ")
import pprint
pp = pprint.PrettyPrinter(indent=2, stream=out)
pp.pprint(mysort(list([(x,list(y.items())) for x,y in tabs.items()])))
out.close()