Mercurial > lcfOS
view cos/utils/bin2c.py @ 154:81e08e2e7777
Used error icon
author | Windel Bouwman |
---|---|
date | Sat, 02 Mar 2013 10:19:38 +0100 |
parents | 47b7df514243 |
children |
line wrap: on
line source
#!/usr/bin/python import sys print(sys.argv) if len(sys.argv) < 2: print('Usage: {0} binfile [headerfile]'.format(sys.argv[0])) sys.exit(-1) with open(sys.argv[1], 'rb') as f: data = f.read() s = ', '.join(hex(b) for b in data) output = 'unsigned char data[] = {{{0}}};'.format(s) if len(sys.argv) < 3: print(output) else: with open(sys.argv[2], 'w') as f: f.write(output)