summaryrefslogtreecommitdiffstatshomepage
path: root/tools/mpy_bin2res.py
blob: 0c89e7e92bf15dea6e777fe04b8269dc785efff4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/usr/bin/env python3
#
# This tool converts binary resource files passed on the command line
# into a Python source file containing data from these files, which can
# be accessed using standard pkg_resources.resource_stream() function
# from micropython-lib:
# https://github.com/micropython/micropython-lib/tree/master/pkg_resources
#
import sys

print("R = {")

for fname in sys.argv[1:]:
    with open(fname, "rb") as f:
        b = f.read()
        print("%r: %r," % (fname, b))

print("}")