<commit_before># Copyright (c) 2014 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 os
import sys

import tvcm
from trace_viewer import trace_viewer_project

def main(args):
  parser = optparse.OptionParser(usage="%prog --outdir=<directory>")
  parser.add_option("--outdir", dest="out_dir",
                    help="Where to place generated content")
  options, args = parser.parse_args(args)

  if not options.out_dir:
    sys.stderr.write("ERROR: Must specify --outdir=<directory>")
    parser.print_help()
    return 1

  filenames = ["extras/about_tracing/about_tracing.html"]
  project = trace_viewer_project.TraceViewerProject()
  load_sequence = project.CalcLoadSequenceForModuleFilenames(filenames)

  olddir = os.getcwd()
  try:
    o = open(os.path.join(options.out_dir, "about_tracing.html"), 'w')
    try:
      tvcm.GenerateStandaloneHTMLToFile(
          o,
          load_sequence,
          title='chrome://tracing',
          flattened_js_url='tracing.js')
    except tvcm.module.DepsException, ex:
      sys.stderr.write("Error: %s\n\n" % str(ex))
      return 255
    o.close()


    o = open(os.path.join(options.out_dir, "about_tracing.js"), 'w')
    tvcm.GenerateJSToFile(
        o,
      load_sequence,
      use_include_tags_for_scripts=True,
      dir_for_include_tag_root=options.out_dir)
    o.close()

  finally:
    os.chdir(olddir)<commit_msg>Open about_tracing files as utf-8 mode<commit_after># Copyright (c) 2014 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 codecs
import optparse
import os
import sys

import tvcm
from trace_viewer import trace_viewer_project

def main(args):
  parser = optparse.OptionParser(usage="%prog --outdir=<directory>")
  parser.add_option("--outdir", dest="out_dir",
                    help="Where to place generated content")
  options, args = parser.parse_args(args)

  if not options.out_dir:
    sys.stderr.write("ERROR: Must specify --outdir=<directory>")
    parser.print_help()
    return 1

  filenames = ["extras/about_tracing/about_tracing.html"]
  project = trace_viewer_project.TraceViewerProject()
  load_sequence = project.CalcLoadSequenceForModuleFilenames(filenames)

  olddir = os.getcwd()
  try:
    o = codecs.open(os.path.join(options.out_dir, "about_tracing.html"), 'w',
                    encoding='utf-8')
    try:
      tvcm.GenerateStandaloneHTMLToFile(
          o,
          load_sequence,
          title='chrome://tracing',
          flattened_js_url='tracing.js')
    except tvcm.module.DepsException, ex:
      sys.stderr.write("Error: %s\n\n" % str(ex))
      return 255
    o.close()


    o = codecs.open(os.path.join(options.out_dir, "about_tracing.js"), 'w',
                    encoding='utf-8')
    assert o.encoding == 'utf-8'
    tvcm.GenerateJSToFile(
        o,
      load_sequence,
      use_include_tags_for_scripts=True,
      dir_for_include_tag_root=options.out_dir)
    o.close()

  finally:
    os.chdir(olddir)
{'fraction_non_alphanumeric': 0.11318960050729232, 'fraction_numerical': 0.0063411540900443885, 'mean_word_length': 3.2462987886944816, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7316467', 'n_tokens_mistral': 1067, 'n_tokens_neox': 1037, 'n_words': 223}