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:
parent
509962abc6
commit
fc528f5733
25
collect_res.py
Executable file
25
collect_res.py
Executable 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
1
src/trezor/res/.gitinit
Normal file
@ -0,0 +1 @@
|
||||
resources.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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user