| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Creates a grd file for packaging the trace-viewer files. | 6 """Creates a grd file for packaging the trace-viewer files. |
| 7 | 7 |
| 8 This file is modified from the devtools generate_devtools_grd.py file. | 8 This file is modified from the devtools generate_devtools_grd.py file. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 | 52 |
| 53 def add_file_to_grd(grd_doc, filename): | 53 def add_file_to_grd(grd_doc, filename): |
| 54 includes_node = grd_doc.getElementsByTagName('if')[0] | 54 includes_node = grd_doc.getElementsByTagName('if')[0] |
| 55 includes_node.appendChild(grd_doc.createTextNode('\n ')) | 55 includes_node.appendChild(grd_doc.createTextNode('\n ')) |
| 56 | 56 |
| 57 new_include_node = grd_doc.createElement('include') | 57 new_include_node = grd_doc.createElement('include') |
| 58 new_include_node.setAttribute('name', make_name_from_filename(filename)) | 58 new_include_node.setAttribute('name', make_name_from_filename(filename)) |
| 59 new_include_node.setAttribute('file', filename) | 59 new_include_node.setAttribute('file', filename) |
| 60 new_include_node.setAttribute('type', 'BINDATA') | 60 new_include_node.setAttribute('type', 'BINDATA') |
| 61 new_include_node.setAttribute('compress', 'gzip') |
| 61 new_include_node.setAttribute('flattenhtml', 'true') | 62 new_include_node.setAttribute('flattenhtml', 'true') |
| 62 if filename.endswith('.html'): | 63 if filename.endswith('.html'): |
| 63 new_include_node.setAttribute('allowexternalscript', 'true') | 64 new_include_node.setAttribute('allowexternalscript', 'true') |
| 64 includes_node.appendChild(new_include_node) | 65 includes_node.appendChild(new_include_node) |
| 65 | 66 |
| 66 | 67 |
| 67 def main(argv): | 68 def main(argv): |
| 68 parsed_args = parse_args(argv[1:]) | 69 parsed_args = parse_args(argv[1:]) |
| 69 | 70 |
| 70 output_directory = os.path.dirname(parsed_args.output_filename) | 71 output_directory = os.path.dirname(parsed_args.output_filename) |
| 71 | 72 |
| 72 doc = minidom.parseString(kGrdTemplate) | 73 doc = minidom.parseString(kGrdTemplate) |
| 73 for filename in parsed_args.source_files: | 74 for filename in parsed_args.source_files: |
| 74 add_file_to_grd(doc, os.path.basename(filename)) | 75 add_file_to_grd(doc, os.path.basename(filename)) |
| 75 | 76 |
| 76 with open(parsed_args.output_filename, 'w') as output_file: | 77 with open(parsed_args.output_filename, 'w') as output_file: |
| 77 output_file.write(doc.toxml(encoding='UTF-8')) | 78 output_file.write(doc.toxml(encoding='UTF-8')) |
| 78 | 79 |
| 79 | 80 |
| 80 if __name__ == '__main__': | 81 if __name__ == '__main__': |
| 81 sys.exit(main(sys.argv)) | 82 sys.exit(main(sys.argv)) |
| OLD | NEW |