1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-27 08:38:07 +00:00

add collect_res script, load frrom resources.py if provided

This commit is contained in:
Pavol Rusnak 2016-05-27 16:48:23 +02:00
parent 509962abc6
commit fc528f5733
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 33 additions and 0 deletions

25
collect_res.py Executable file
View File

@ -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))

1
src/trezor/res/.gitinit Normal file
View File

@ -0,0 +1 @@
resources.py

View File

@ -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()