<commit_before>/*
Copyright 2011 Opera Software ASA

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.opera.core.systems;

import com.opera.core.systems.preferences.OperaFilePreferences;
import com.opera.core.systems.preferences.OperaGenericPreferences;
import com.opera.core.systems.preferences.OperaPreferences;

import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.io.TemporaryFilesystem;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.io.File;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.logging.Logger;

import static com.google.common.base.Preconditions.checkArgument;

/**
 * OperaProfile is an interface representing a profile (commonly a profile directory) for the Opera
 * web browser.  It's typically used by passing in an instance object of this class to the
 * "opera.profile" capability at construction of {@link OperaDriver}, like this:
 *
 * <pre>
 * {@code
 *   DesiredCapabilities capabilities = DesiredCapabilities.opera();
 *   OperaProfile profile = new OperaProfile();
 *
 *   profile.preferences().set("foo", "bar", "baz");
 *   capabilities.setCapability("opera.profile", profile);
 *
 *   WebDriver driver = new OperaDriver(capabilities);
 * }
 * </pre>
 *
 * Or by passing it in as an object directly to {@link OperaDriver}'s constructor:
 *
 * <pre>
 * {@code
 *   OperaProfile profile = new OperaProfile();
 *   profile.preferences().set("foo", "bar", "baz");
 *
 *   WebDriver driver = new OperaDriver(profile);
 * }
 * </pre>
 *
 * Among Opera's command-line arguments the profile may be referred to as "pd", short for "personal
 * directory".
 *
 * @see OperaPreferences
 */
public class OperaProfile {

  private File directory;
  private File preferenceFile;
  private boolean randomProfile = false;
  private OperaPreferences preferences;
  private final Logger logger = Logger.getLogger(getClass().getName());

  /**
   * Creates a new, fresh random profile for Opera to use.  The actual profile directory will not be
   * generated until Opera is started.
   */
  public OperaProfile() {
    this(TemporaryFilesystem.getDefaultTmpFS().createTempDir("opera", "profile"));
    randomProfile = true;
  }

  /**
   * Creates a representation of the profile in the given directory path.  If you specify a profile
   * directory that does not exist Opera will generate a new, fresh profile in the same location
   * when it is started.
   *
   * @param profileDirectoryPath the path to the profile directory to use
   */
  public OperaProfile(String profileDirectoryPath) {
    this(new File(profileDirectoryPath));<commit_msg>Adding some debugging logging<commit_after>/*
Copyright 2011 Opera Software ASA

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.opera.core.systems;

import com.opera.core.systems.preferences.OperaFilePreferences;
import com.opera.core.systems.preferences.OperaGenericPreferences;
import com.opera.core.systems.preferences.OperaPreferences;

import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.io.TemporaryFilesystem;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.io.File;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.logging.Logger;

import static com.google.common.base.Preconditions.checkArgument;

/**
 * OperaProfile is an interface representing a profile (commonly a profile directory) for the Opera
 * web browser.  It's typically used by passing in an instance object of this class to the
 * "opera.profile" capability at construction of {@link OperaDriver}, like this:
 *
 * <pre>
 * {@code
 *   DesiredCapabilities capabilities = DesiredCapabilities.opera();
 *   OperaProfile profile = new OperaProfile();
 *
 *   profile.preferences().set("foo", "bar", "baz");
 *   capabilities.setCapability("opera.profile", profile);
 *
 *   WebDriver driver = new OperaDriver(capabilities);
 * }
 * </pre>
 *
 * Or by passing it in as an object directly to {@link OperaDriver}'s constructor:
 *
 * <pre>
 * {@code
 *   OperaProfile profile = new OperaProfile();
 *   profile.preferences().set("foo", "bar", "baz");
 *
 *   WebDriver driver = new OperaDriver(profile);
 * }
 * </pre>
 *
 * Among Opera's command-line arguments the profile may be referred to as "pd", short for "personal
 * directory".
 *
 * @see OperaPreferences
 */
public class OperaProfile {

  private File directory;
  private File preferenceFile;
  private boolean randomProfile = false;
  private OperaPreferences preferences;
  private final Logger logger = Logger.getLogger(getClass().getName());

  /**
   * Creates a new, fresh random profile for Opera to use.  The actual profile directory will not be
   * generated until Opera is started.
   */
  public OperaProfile() {
    this(TemporaryFilesystem.getDefaultTmpFS().createTempDir("opera", "profile"));
    logger.warning("Using a random profile from TemporaryFilesystem, this is likely to cause issues with JUnit");
    randomProfile = true;
  }

  /**
   * Creates a representation of the profile in the given directory path.  If you specify a profile
   * directory that does not exist Opera will generate a new, fresh profile in the same location
   * when it is started.
   *
   * @param profileDirectoryPath the path to the profile directory to use
   */
  public OperaProfile(String profileDirectoryPath) {
    this(new File(profileDirectoryPath));
{'fraction_non_alphanumeric': 0.09231974921630094, 'fraction_numerical': 0.0025078369905956114, 'mean_word_length': 4.384810126582279, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1515', 'n_tokens_mistral': 1732, 'n_tokens_neox': 1691, 'n_words': 640}