diff --git a/collect_res.py b/collect_res.py new file mode 100755 index 0000000000..ba26b801b8 --- /dev/null +++ b/collect_res.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 +import os + +resources = {} + +def process_file(name): + if name.endswith('.py'): + return + with open(name, 'rb') as f: + resources[name] = f.read() + +# scan generic resources +for res in os.scandir('src/trezor/res/'): + if res.is_file(): + process_file('src/trezor/res/%s' % res.name) + +# scan apps +for app in os.scandir('src/apps/'): + if app.is_dir(): + for res in os.scandir('src/apps/%s/res/' % app.name): + if res.is_file(): + process_file('src/apps/%s/res/%s' % (app.name, res.name)) + +with open('src/trezor/res/resources.py', 'wt') as f: + f.write('resdata = ' + str(resources)) diff --git a/src/trezor/res/.gitinit b/src/trezor/res/.gitinit new file mode 100644 index 0000000000..adbe64639b --- /dev/null +++ b/src/trezor/res/.gitinit @@ -0,0 +1 @@ +resources.py diff --git a/src/trezor/res/__init__.py b/src/trezor/res/__init__.py index 06a7f448de..e5677e7472 100644 --- a/src/trezor/res/__init__.py +++ b/src/trezor/res/__init__.py @@ -1,4 +1,11 @@ +try: + from .resources import resdata +except ImportError: + resdata = None + def loadres(name): + if resdata and name in resdata: + return resdata[name] with open(name, 'rb') as f: return f.read()