Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: runtime/tools/create_resources.py

Issue 317873003: Rewrite Windows path separator to be Unix path separator in Observatory resource bundle (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 # Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 # for details. All rights reserved. Use of this source code is governed by a 2 # for details. All rights reserved. Use of this source code is governed by a
3 # BSD-style license that can be found in the LICENSE file. 3 # BSD-style license that can be found in the LICENSE file.
4 # 4 #
5 # This python script creates string literals in a C++ source file from a C++ 5 # This python script creates string literals in a C++ source file from a C++
6 # source template and one or more resource files. 6 # source template and one or more resource files.
7 7
8 import os 8 import os
9 import sys 9 import sys
10 from os.path import join 10 from os.path import join
(...skipping 22 matching lines...) Expand all
33 lineCounter = 0 33 lineCounter = 0
34 for byte in fileHandle.read(): 34 for byte in fileHandle.read():
35 result += r" '\x%02x'," % ord(byte) 35 result += r" '\x%02x'," % ord(byte)
36 lineCounter += 1 36 lineCounter += 1
37 if lineCounter == 10: 37 if lineCounter == 10:
38 result += '\n ' 38 result += '\n '
39 lineCounter = 0 39 lineCounter = 0
40 if lineCounter != 0: 40 if lineCounter != 0:
41 result += '\n ' 41 result += '\n '
42 result += ' 0\n};\n\n' 42 result += ' 0\n};\n\n'
43 resource_url_scrubbed = re.sub(r'\\', '', resource_url) 43 resource_url_scrubbed = re.sub(r'\\', '/', resource_url)
44 resources.append( 44 resources.append(
45 (resource_url_scrubbed, resource_name, os.stat(resource_file).st_size)); 45 (resource_url_scrubbed, resource_name, os.stat(resource_file).st_size));
46 46
47 # Write the resource table. 47 # Write the resource table.
48 result += 'ResourcesEntry __%s_resources_[] = ' % table_name 48 result += 'ResourcesEntry __%s_resources_[] = ' % table_name
49 result += '{\n' 49 result += '{\n'
50 for res in resources: 50 for res in resources:
51 result += ' { "%s", %s, %d },\n' % res 51 result += ' { "%s", %s, %d },\n' % res
52 result += ' { 0, 0, 0 },\n' 52 result += ' { 0, 0, 0 },\n'
53 result += '};\n\n' 53 result += '};\n\n'
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 return 0 143 return 0
144 except Exception, inst: 144 except Exception, inst:
145 sys.stderr.write('create_resources.py exception\n') 145 sys.stderr.write('create_resources.py exception\n')
146 sys.stderr.write(str(inst)) 146 sys.stderr.write(str(inst))
147 sys.stderr.write('\n') 147 sys.stderr.write('\n')
148 return -1 148 return -1
149 149
150 if __name__ == '__main__': 150 if __name__ == '__main__':
151 sys.exit(main(sys.argv)) 151 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698