-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconvert_libs.py
More file actions
31 lines (26 loc) · 777 Bytes
/
convert_libs.py
File metadata and controls
31 lines (26 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"""
Convert the .bicicleta/.expected files into a .js that's easy to load.
(Yes, I should learn the right way to load data files in JS.)
"""
import glob
def main():
gen('sys')
gen('examples')
def gen(dirname):
print 'var %s = {' % dirname
for path in glob.glob(dirname+'/*.bicicleta'):
name = path.replace(dirname+'/', '').replace('.bicicleta', '')
with open(path) as f:
text = f.read()
print ' %r: %r,' % (name, text)
try:
f = open(path.replace('.bicicleta', '.expected'))
except IOError:
pass
else:
with f:
expected = f.read()
print ' %r: %r,' % (name+'.expected', expected)
print '};'
if __name__ == '__main__':
main()