2016-05-27 14:48:23 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
|
|
|
|
resources = {}
|
|
|
|
|
2016-09-26 13:13:33 +00:00
|
|
|
os.chdir('../src/')
|
2016-05-31 12:31:28 +00:00
|
|
|
|
2016-05-27 14:48:23 +00:00
|
|
|
def process_file(name):
|
2016-05-31 12:31:28 +00:00
|
|
|
if name.endswith('.gitignore'):
|
|
|
|
return
|
2016-05-27 14:48:23 +00:00
|
|
|
if name.endswith('.py'):
|
|
|
|
return
|
2016-09-25 22:24:16 +00:00
|
|
|
print('processing file %s' % name)
|
2016-05-27 14:48:23 +00:00
|
|
|
with open(name, 'rb') as f:
|
2016-09-26 13:13:33 +00:00
|
|
|
resources[name] = f.read()
|
2016-05-27 14:48:23 +00:00
|
|
|
|
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/'):
|
2016-05-27 14:48:23 +00:00
|
|
|
if res.is_file():
|
2016-09-26 13:13:33 +00:00
|
|
|
process_file('trezor/res/%s' % res.name)
|
2016-05-27 14:48:23 +00:00
|
|
|
|
|
|
|
# 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):
|
2016-05-27 14:48:23 +00:00
|
|
|
if res.is_file():
|
2016-09-26 13:13:33 +00:00
|
|
|
process_file('apps/%s/res/%s' % (app.name, res.name))
|
2016-05-27 14:48:23 +00:00
|
|
|
|
2016-09-26 13:13:33 +00:00
|
|
|
resfile = 'trezor/res/resources.py'
|
2016-09-25 22:24:16 +00:00
|
|
|
with open(resfile, 'wt') as f:
|
2016-05-31 12:31:28 +00:00
|
|
|
f.write('resdata = {\n')
|
|
|
|
for k in sorted(resources.keys()):
|
|
|
|
f.write(" '%s': %s,\n" % (k, resources[k]))
|
|
|
|
f.write('}\n')
|
2016-09-25 22:24:16 +00:00
|
|
|
|
|
|
|
print('written %s with %d entries' % (resfile, len(resources)))
|