<commit_before># 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 logging

from devil.android import device_errors


class FlagChanger(object):
  """Changes the flags Chrome runs with.

    Flags can be temporarily set for a particular set of unit tests.  These
    tests should call Restore() to revert the flags to their original state
    once the tests have completed.
  """

  def __init__(self, device, cmdline_file):
    """Initializes the FlagChanger and records the original arguments.

    Args:
      device: A DeviceUtils instance.
      cmdline_file: Path to the command line file on the device.
    """
    self._device = device

    # Unrooted devices have limited access to the file system,
    # as do all devices on Nougat thanks to tighter SELinux controls.
    # Place files in /data/local/tmp/ rather than /data/local/
    if ((not device.HasRoot() or device.build_type in ('eng', 'userdebug'))
        and not '/data/local/tmp/' in cmdline_file):
      self._cmdline_file = cmdline_file.replace('/data/local/',
                                                '/data/local/tmp/')
    else:
      self._cmdline_file = cmdline_file

    stored_flags = ''
    if self._device.PathExists(self._cmdline_file):
      try:
        stored_flags = self._device.ReadFile(self._cmdline_file).strip()<commit_msg>Revert of [devil] Use /data/local/tmp for the command line on eng + userdebug builds. (patchset #2 id:20001 of https://codereview.chromium.org/2275863002/ )<commit_after># 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 logging

from devil.android import device_errors


class FlagChanger(object):
  """Changes the flags Chrome runs with.

    Flags can be temporarily set for a particular set of unit tests.  These
    tests should call Restore() to revert the flags to their original state
    once the tests have completed.
  """

  def __init__(self, device, cmdline_file):
    """Initializes the FlagChanger and records the original arguments.

    Args:
      device: A DeviceUtils instance.
      cmdline_file: Path to the command line file on the device.
    """
    self._device = device

    # Unrooted devices have limited access to the file system.
    # Place files in /data/local/tmp/ rather than /data/local/
    if not device.HasRoot() and not '/data/local/tmp/' in cmdline_file:
      self._cmdline_file = cmdline_file.replace('/data/local/',
                                                '/data/local/tmp/')
    else:
      self._cmdline_file = cmdline_file

    stored_flags = ''
    if self._device.PathExists(self._cmdline_file):
      try:
        stored_flags = self._device.ReadFile(self._cmdline_file).strip()
{'fraction_non_alphanumeric': 0.08333333333333333, 'fraction_numerical': 0.008264462809917356, 'mean_word_length': 2.8733333333333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1539529', 'n_tokens_mistral': 831, 'n_tokens_neox': 795, 'n_words': 309}