Skip to content

Commit a3cd349

Browse files
committed
tools/mpy_bin2res: Tools to convert binary resources to Python module.
Afterwards, they can be access using pkg_resource module from micropython-lib.
1 parent 653a0c2 commit a3cd349

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tools/mpy_bin2res.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python3
2+
#
3+
# This tool converts binary resource files passed on the command line
4+
# into a Python source file containing data from these files, which can
5+
# be accessed using standard pkg_resources.resource_stream() function
6+
# from micropython-lib:
7+
# https://github.com/micropython/micropython-lib/tree/master/pkg_resources
8+
#
9+
import sys
10+
11+
print("R = {")
12+
13+
for fname in sys.argv[1:]:
14+
with open(fname, "rb") as f:
15+
b = f.read()
16+
print("%r: %r," % (fname, b))
17+
18+
print("}")

0 commit comments

Comments
 (0)