2016-05-27 14:48:23 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
|
|
|
|
resources = {}
|
|
|
|
|
2016-05-31 12:31:28 +00:00
|
|
|
os.chdir('..')
|
|
|
|
|
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
|
|
|
|
with open(name, 'rb') as f:
|
|
|
|
resources[name] = f.read()
|
|
|
|
|
2016-05-28 01:24:58 +00:00
|
|
|
# scan common resources
|
2016-05-27 14:48:23 +00:00
|
|
|
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/'):
|
2016-05-31 12:31:28 +00:00
|
|
|
if app.is_dir() and os.path.isdir('src/apps/%s/res/' % app.name):
|
2016-05-27 14:48:23 +00:00
|
|
|
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:
|
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')
|