<commit_before># Copyright 2013 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.
"""Finds desktop browsers that can be controlled by telemetry."""

import logging
import os
import sys

from telemetry.core import browser
from telemetry.core import possible_browser
from telemetry.core import platform
from telemetry.core import util
from telemetry.core.backends.webdriver import webdriver_ie_backend
from telemetry.page import cloud_storage

# Try to import the selenium python lib which may be not available.
util.AddDirToPythonPath(
    util.GetChromiumSrcDir(), 'third_party', 'webdriver', 'pylib')
try:
  from selenium import webdriver  # pylint: disable=F0401
except ImportError:
  webdriver = None

ALL_BROWSER_TYPES = ''
if webdriver:
  ALL_BROWSER_TYPES = ','.join([
      'internet-explorer',
      'internet-explorer-x64'])
else:
  logging.warning('Webdriver backend is unsupported without selenium pylib. '
                  'For installation of selenium pylib, please refer to '
                  'https://code.google.com/p/selenium/wiki/PythonBindings.')


class PossibleWebDriverBrowser(possible_browser.PossibleBrowser):
  """A browser that can be controlled through webdriver API."""

  def __init__(self, browser_type, finder_options):
    super(PossibleWebDriverBrowser, self).__init__(browser_type, finder_options)

  def CreateWebDriverBackend(self, platform_backend):
    raise NotImplementedError()

  def Create(self):
    platform_backend = platform.CreatePlatformBackendForCurrentOS()
    backend = self.CreateWebDriverBackend(platform_backend)
    b = browser.Browser(backend, platform_backend)
    return b

  def SupportsOptions(self, finder_options):
    # TODO(chrisgao): Check if some options are not supported.
    return True

  @property
  def last_modification_time(self):
    return -1


class PossibleDesktopIE(PossibleWebDriverBrowser):
  def __init__(self, browser_type, finder_options, architecture):
    super(PossibleDesktopIE, self).__init__(browser_type, finder_options)
    self._architecture = architecture

  def CreateWebDriverBackend(self, platform_backend):
    assert webdriver<commit_msg>Webdriver does not support extensions.<commit_after># Copyright 2013 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.
"""Finds desktop browsers that can be controlled by telemetry."""

import logging
import os
import sys

from telemetry.core import browser
from telemetry.core import possible_browser
from telemetry.core import platform
from telemetry.core import util
from telemetry.core.backends.webdriver import webdriver_ie_backend
from telemetry.page import cloud_storage

# Try to import the selenium python lib which may be not available.
util.AddDirToPythonPath(
    util.GetChromiumSrcDir(), 'third_party', 'webdriver', 'pylib')
try:
  from selenium import webdriver  # pylint: disable=F0401
except ImportError:
  webdriver = None

ALL_BROWSER_TYPES = ''
if webdriver:
  ALL_BROWSER_TYPES = ','.join([
      'internet-explorer',
      'internet-explorer-x64'])
else:
  logging.warning('Webdriver backend is unsupported without selenium pylib. '
                  'For installation of selenium pylib, please refer to '
                  'https://code.google.com/p/selenium/wiki/PythonBindings.')


class PossibleWebDriverBrowser(possible_browser.PossibleBrowser):
  """A browser that can be controlled through webdriver API."""

  def __init__(self, browser_type, finder_options):
    super(PossibleWebDriverBrowser, self).__init__(browser_type, finder_options)

  def CreateWebDriverBackend(self, platform_backend):
    raise NotImplementedError()

  def Create(self):
    platform_backend = platform.CreatePlatformBackendForCurrentOS()
    backend = self.CreateWebDriverBackend(platform_backend)
    b = browser.Browser(backend, platform_backend)
    return b

  def SupportsOptions(self, finder_options):
    if len(finder_options.extensions_to_load) != 0:
      return False
    return True

  @property
  def last_modification_time(self):
    return -1


class PossibleDesktopIE(PossibleWebDriverBrowser):
  def __init__(self, browser_type, finder_options, architecture):
    super(PossibleDesktopIE, self).__init__(browser_type, finder_options)
    self._architecture = architecture

  def CreateWebDriverBackend(self, platform_backend):
    assert webdriver
{'fraction_non_alphanumeric': 0.07683766377970241, 'fraction_numerical': 0.005107705973795247, 'mean_word_length': 4.796653796653796, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3320372', 'n_tokens_mistral': 1325, 'n_tokens_neox': 1237, 'n_words': 376}