blob: 4697b31911c08c7b9959d64dfe3375d8a8f5ed14 (
plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#!/usr/bin/python
#coding:utf-8
import os
import sys
if len(sys.argv) != 2:
print('usage;./' + os.path.basename(__file__) + ' VerticalOrientation.txt')
sys.exit(1)
#pick up all data from text
data = []
f = open(sys.argv[1], 'r')
for line in f:
line = line.split("#")[0].strip()
if len(line) == 0:
continue
coderange, vo = line.split(";")
vo = vo.strip()
codes = coderange.split("..")
if len(codes) == 1:
st = int(codes[0], 16)
ed = st
else:
st = int(codes[0], 16)
ed = int(codes[1], 16)
data.append([st, ed, vo])
f.close()
#compress all data, replace Tu to U and Tr to R.
compressed = []
t = []
for d in data:
if d[2] == 'Tu': d[2] = 'U'
if d[2] == 'Tr': d[2] = 'R'
if t == []:
t = d
else:
if t[2] == d[2] and t[1] + 1 == d[0]:
t[1] = d[1]
else:
compressed.append(t)
t = d
compressed.append(t)
#dump vo=U
for d in compressed:
if d[2] == 'U':
print('{0x%04X, 0x%04X},' % tuple(d[0:2]))
|