summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-07-27 14:41:27 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2017-07-27 14:41:27 +0300
commita3cd349eafb2f612379f10c45ab1ad4175e322e2 (patch)
tree17ebcce587700f402574960cd70f70e9671fec04
parent653a0c2d71100998a9cce0b7e2eb29ce54014aab (diff)
downloadmicropython-a3cd349eafb2f612379f10c45ab1ad4175e322e2.tar.gz
micropython-a3cd349eafb2f612379f10c45ab1ad4175e322e2.zip
tools/mpy_bin2res: Tools to convert binary resources to Python module.
Afterwards, they can be access using pkg_resource module from micropython-lib.
-rwxr-xr-xtools/mpy_bin2res.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/tools/mpy_bin2res.py b/tools/mpy_bin2res.py
new file mode 100755
index 0000000000..0c89e7e92b
--- /dev/null
+++ b/tools/mpy_bin2res.py
@@ -0,0 +1,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("}")