summaryrefslogtreecommitdiffstats
path: root/webkit/build/generate_devtools_html.py
blob: 5160fc2414812aa0e2cfb42f29a357fa3cce3d26 (plain)
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
32
33
34
35
36
37
#!/usr/bin/env python
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os.path
import sys

def GenerateIncludeTag(resource_path):
  (dir_name, file_name) = os.path.split(resource_path)
  if (file_name.endswith('.js')):
    return '    <script type="text/javascript" src="%s"></script>\n' % file_name
  elif (file_name.endswith('.css')):
    return '    <link rel="stylesheet" type="text/css" href="%s">\n' % file_name
  else:
    assert false


def main(argv):

  if len(argv) < 4:
    print 'usage: %s inspector_html devtools_html css_and_js_files_list' % argv[0]
    return 1

  inspector_html = open(argv[1], 'r')
  devtools_html = open(argv[2], 'w')

  for line in inspector_html:
    if '</head>' in line:
      devtools_html.write('\n    <!-- The following lines are added to include DevTools resources -->\n')
      for resource in argv[3:]:
        devtools_html.write(GenerateIncludeTag(resource))
      devtools_html.write('    <!-- End of auto-added files list -->\n')
    devtools_html.write(line)

if __name__ == '__main__':
  sys.exit(main(sys.argv))