old_contents: #!/usr/bin/env python
  # Copyright (c) 2012 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 optparse
  import parse_deps
  import sys
  import os
  
  srcdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../src"))
  
  js_warning_message = """/**
  // Copyright (c) 2012 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.
  
  * WARNING: This file is generated by generate_standalone_timeline_view.py
  *
  *        Do not edit directly.
  */
  """
  
  css_warning_message = """/**
  /* Copyright (c) 2012 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. */
  
  * WARNING: This file is generated by generate_standalone_timeline_view.py
  *
  *        Do not edit directly.
  */
  """
  def _get_input_filenames():
    return [os.path.join(srcdir, f)
            for f in ['base.js', 'timeline_view.js']]
  
  def generate_css():
    filenames = _get_input_filenames()
    load_sequence = parse_deps.calc_load_sequence(filenames)
  
    style_sheet_chunks = [css_warning_message, '\n']
    for module in load_sequence:
      for style_sheet in module.style_sheets:
        style_sheet_chunks.append("""%s\n""" % style_sheet.timeline_view)
  
    return ''.join(style_sheet_chunks)
  
  def generate_js():
    filenames = _get_input_filenames()
    load_sequence = parse_deps.calc_load_sequence(filenames)
  
    js_chunks = [js_warning_message, '\n']
    js_chunks.append("window.FLATTENED = {};\n")
  
    for module in load_sequence:
      js_chunks.append( "window.FLATTENED['%s'] = true;\n" % module.name)
  
    for module in load_sequence:
      js_chunks.append(module.contents)
      js_chunks.append("\n")
  
    return ''.join(js_chunks)
  
  def main(args):
    parser = optparse.OptionParser()
    parser.add_option("--js", dest="js_file",
                      help="Where to place generated javascript file")
    parser.add_option("--css", dest="css_file",
                      help="Where to place generated css file")
    options, args = parser.parse_args(args)
  
    if not options.js_file and not options.css_file:
      print "Must specify one, or both of --js and --css"
      return 1
  
    if options.js_file:
      with open(options.js_file, 'w') as f:
        f.write(generate_js())
  
    if options.css_file:
      with open(options.css_file, 'w') as f:
        f.write(generate_css())
  
    return 0
  
  
  if __name__ == "__main__":
    sys.exit(main(sys.argv))
  
new_contents: #!/usr/bin/env python
  # Copyright (c) 2012 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 optparse
  import parse_deps
  import sys
  import os
  
  srcdir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../src"))
  
  js_warning_message = """/**
  // Copyright (c) 2012 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.
  
  * WARNING: This file is generated by generate_standalone_timeline_view.py
  *
  *        Do not edit directly.
  */
  """
  
  css_warning_message = """/**
  /* Copyright (c) 2012 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. */
  
  * WARNING: This file is generated by generate_standalone_timeline_view.py
  *
  *        Do not edit directly.
  */
  """
  def _get_input_filenames():
    return [os.path.join(srcdir, f)
            for f in ['base.js', 'timeline_view.js']]
  
  def generate_css():
    filenames = _get_input_filenames()
    load_sequence = parse_deps.calc_load_sequence(filenames)
  
    style_sheet_chunks = [css_warning_message, '\n']
    for module in load_sequence:
      for style_sheet in module.style_sheets:
        style_sheet_chunks.append("""%s\n""" % style_sheet.contents)
  
    return ''.join(style_sheet_chunks)
  
  def generate_js():
    filenames = _get_input_filenames()
    load_sequence = parse_deps.calc_load_sequence(filenames)
  
    js_chunks = [js_warning_message, '\n']
    js_chunks.append("window.FLATTENED = {};\n")
  
    for module in load_sequence:
      js_chunks.append( "window.FLATTENED['%s'] = true;\n" % module.name)
  
    for module in load_sequence:
      js_chunks.append(module.contents)
      js_chunks.append("\n")
  
    return ''.join(js_chunks)
  
  def main(args):
    parser = optparse.OptionParser()
    parser.add_option("--js", dest="js_file",
                      help="Where to place generated javascript file")
    parser.add_option("--css", dest="css_file",
                      help="Where to place generated css file")
    options, args = parser.parse_args(args)
  
    if not options.js_file and not options.css_file:
      print "Must specify one, or both of --js and --css"
      return 1
  
    if options.js_file:
      with open(options.js_file, 'w') as f:
        f.write(generate_js())
  
    if options.css_file:
      with open(options.css_file, 'w') as f:
        f.write(generate_css())
  
    return 0
  
  
  if __name__ == "__main__":
    sys.exit(main(sys.argv))
  
subject: Fix typo in previous generator commits