diff options
author | Raghuram Subramani <raghus2247@gmail.com> | 2022-06-19 19:47:51 +0530 |
---|---|---|
committer | Raghuram Subramani <raghus2247@gmail.com> | 2022-06-19 19:47:51 +0530 |
commit | 4fd287655a72b9aea14cdac715ad5b90ed082ed2 (patch) | |
tree | 65d393bc0e699dd12d05b29ba568e04cea666207 /circuitpython/tools/mpy_bin2res.py | |
parent | 0150f70ce9c39e9e6dd878766c0620c85e47bed0 (diff) |
add circuitpython code
Diffstat (limited to 'circuitpython/tools/mpy_bin2res.py')
-rwxr-xr-x | circuitpython/tools/mpy_bin2res.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/circuitpython/tools/mpy_bin2res.py b/circuitpython/tools/mpy_bin2res.py new file mode 100755 index 0000000..8d67b71 --- /dev/null +++ b/circuitpython/tools/mpy_bin2res.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python3 + +# SPDX-FileCopyrightText: 2014 MicroPython & CircuitPython contributors (https://github.com/adafruit/circuitpython/graphs/contributors) +# +# SPDX-License-Identifier: MIT + +# +# 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("}") |