#!/usr/bin/env python3

import os
import sys

MAX = 8

fpath = sys.argv[1]
name = sys.argv[2]

with open(fpath, "rb") as fh:
    sys.stdout.write("char %s[] = {" % (name,) )

    i = 0
    while True:
        if i > 0:
            sys.stdout.write(", ")

        if i % MAX == 0:
            sys.stdout.write("\n\t")

        c = fh.read(1)

        if not c:
            sys.stdout.write("\n")
            break

        sys.stdout.write("0x%.2x" % (ord(c), ))

        i = i + 1

    print("};")
    print("")
    print("unsigned int %s_sz = %s;" % (name, i))
    print("")


[((12, 4, 12, 48), 'sys.stdout.write', 'sys.stdout.write', ({(12, 21, 12, 46): "('char %s[] = {' % (name,))"}, {}), "('char %s[] = {' % (name,))", False, 'import sys\n'), ((17, 12, 17, 34), 'sys.stdout.write', 'sys.stdout.write', ({(17, 29, 17, 33): '""", """'}, {}), "(', ')", False, 'import sys\n'), ((20, 12, 20, 36), 'sys.stdout.write', 'sys.stdout.write', ({(20, 29, 20, 35): '"""\n\t"""'}, {}), "('\\n\\t')", False, 'import sys\n'), ((25, 12, 25, 34), 'sys.stdout.write', 'sys.stdout.write', ({(25, 29, 25, 33): '"""\n"""'}, {}), "('\\n')", False, 'import sys\n')]