2016-05-27 14:48:23 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
|
|
|
|
resources = {}
|
2016-10-03 09:56:24 +00:00
|
|
|
resources_size = 0
|
2016-05-27 14:48:23 +00:00
|
|
|
|
2016-09-29 11:35:00 +00:00
|
|
|
os.chdir(os.path.dirname(__file__))
|
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
|
|
|
|
with open(name, 'rb') as f:
|
2016-10-03 09:56:24 +00:00
|
|
|
data = f.read()
|
|
|
|
resources[name] = data
|
|
|
|
print('processing file %s (%d bytes)' % (name, len(data)))
|
|
|
|
global resources_size
|
|
|
|
resources_size += len(data)
|
2016-05-27 14:48:23 +00:00
|
|
|
|
2016-05-28 01:24:58 +00:00
|
|
|
# scan common resources
|
2016-09-27 13:40:57 +00:00
|
|
|
for res in os.listdir('trezor/res/'):
|
|
|
|
name = os.path.join('trezor/res/', res)
|
|
|
|
if os.path.isfile(name):
|
|
|
|
process_file(name)
|
2016-05-27 14:48:23 +00:00
|
|
|
|
|
|
|
# scan apps
|
2016-09-27 13:40:57 +00:00
|
|
|
for app in os.listdir('apps/'):
|
|
|
|
name = os.path.join('apps/', app)
|
|
|
|
if os.path.isdir(name) and os.path.isdir('apps/%s/res/' % app):
|
|
|
|
for res in os.listdir('apps/%s/res/' % app):
|
|
|
|
name = 'apps/%s/res/%s' % (app, res)
|
|
|
|
if os.path.isfile(name):
|
|
|
|
process_file(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
|
|
|
|
2016-10-03 09:56:24 +00:00
|
|
|
print('written %s with %d entries (total %d bytes)' % (resfile, len(resources), resources_size))
|