1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-29 10:58:21 +00:00
trezor-firmware/tools/res_collect.py

37 lines
974 B
Python
Raw Normal View History

#!/usr/bin/env python3
import os
resources = {}
2016-09-26 13:13:33 +00:00
os.chdir('../src/')
def process_file(name):
if name.endswith('.gitignore'):
return
if name.endswith('.py'):
return
print('processing file %s' % name)
with open(name, 'rb') as f:
2016-09-26 13:13:33 +00:00
resources[name] = f.read()
2016-05-28 01:24:58 +00:00
# scan common resources
2016-09-26 13:13:33 +00:00
for res in os.scandir('trezor/res/'):
if res.is_file():
2016-09-26 13:13:33 +00:00
process_file('trezor/res/%s' % res.name)
# scan apps
2016-09-26 13:13:33 +00:00
for app in os.scandir('apps/'):
if app.is_dir() and os.path.isdir('apps/%s/res/' % app.name):
for res in os.scandir('apps/%s/res/' % app.name):
if res.is_file():
2016-09-26 13:13:33 +00:00
process_file('apps/%s/res/%s' % (app.name, res.name))
2016-09-26 13:13:33 +00:00
resfile = 'trezor/res/resources.py'
with open(resfile, 'wt') as f:
f.write('resdata = {\n')
for k in sorted(resources.keys()):
f.write(" '%s': %s,\n" % (k, resources[k]))
f.write('}\n')
print('written %s with %d entries' % (resfile, len(resources)))