ft8_lib/utils/convert_generator.py

17 lines
332 B
Python
Raw Permalink Normal View History

2018-10-18 15:42:43 +08:00
import sys
2018-10-26 16:43:16 +08:00
import re
rx1 = re.compile(r'"([0-9a-z]+)"', re.I)
2018-10-18 15:42:43 +08:00
for line in sys.stdin:
line = line.strip()
2018-10-26 16:43:16 +08:00
m = rx1.search(line)
if m == None:
continue
line = m.group(1)
if len(line) % 2 == 1:
line += '0'
2018-10-18 15:42:43 +08:00
b = ['0x' + line[i*2:i*2+2] for i in range(len(line)/2)]
print '{ %s },' % (', '.join(b))