Mercurial > lcfOS
view python/bin2c.py @ 242:c94965418684
Added tag burnchain for changeset ce6d390043a7
author | Windel Bouwman |
---|---|
date | Mon, 22 Jul 2013 22:56:51 +0200 |
parents | 8b2e5f3cd579 |
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)