<commit_before># -*- coding: utf-8 -*-

from __future__ import absolute_import

import functools
import logging
logging.basicConfig(level=logging.INFO)
import time
try:
    from urlparse import urlparse, urlunparse
    from urllib import urlencode
except ImportError:
    from urllib.parse import urlparse, urlunparse, urlencode

import six
try:
    input = raw_input
except NameError:
    pass

import selenium.common.exceptions as selenium_exc
from selenium.webdriver import *
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.ui import Select, WebDriverWait

from .download import DownloadUrl, DownloadFile
from .errors import WebdriverWrapperErrorMixin
from .exceptions import _create_exception_msg
from .info import WebdriverWrapperInfoMixin
from .utils import force_text

__all__ = (
    'Firefox',
    'FirefoxProfile',
    'Chrome',
    'ChromeOptions',
    'Ie',
    'Opera',
    'PhantomJS',
    'Remote',
    'DesiredCapabilities',
    'ActionChains',
    'TouchActions',
    'Proxy',
)


class _ConvertToWebelementWrapper(object):
    def __call__(self, f):
        @functools.wraps(f)
        def wrapper(*args, **kwds):
            res = f(*args, **kwds)
            res = self._convert_result(res)
            return res
        return wrapper

    @classmethod
    def _convert_result(cls, res):
        if type(res) is WebElement:
            res = cls._convert_into_webelementwrapper(res)
        elif isinstance(res, (list, tuple)):
            for index, item in enumerate(res):
                res[index] = cls._convert_result(item)
        return res

    @classmethod
    def _convert_into_webelementwrapper(cls, webelement):
        try:
            if webelement.tag_name == 'form':
                from webdriverwrapper.forms import Form
                wrapped = Form(webelement)
            elif webelement.tag_name == 'select':
                wrapped = _SelectWrapper(webelement)
            else:<commit_msg>#10 Partial fix of Firefox with Selenium 3<commit_after># -*- coding: utf-8 -*-

from __future__ import absolute_import

import functools
import logging
logging.basicConfig(level=logging.INFO)
import time
try:
    from urlparse import urlparse, urlunparse
    from urllib import urlencode
except ImportError:
    from urllib.parse import urlparse, urlunparse, urlencode

import six
try:
    input = raw_input
except NameError:
    pass

import selenium.common.exceptions as selenium_exc
from selenium.webdriver import *
from selenium.webdriver.common.alert import Alert
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.ui import Select, WebDriverWait

from .download import DownloadUrl, DownloadFile
from .errors import WebdriverWrapperErrorMixin
from .exceptions import _create_exception_msg
from .info import WebdriverWrapperInfoMixin
from .utils import force_text

__all__ = (
    'Firefox',
    'FirefoxProfile',
    'Chrome',
    'ChromeOptions',
    'Ie',
    'Opera',
    'PhantomJS',
    'Remote',
    'DesiredCapabilities',
    'ActionChains',
    'TouchActions',
    'Proxy',
)


class _ConvertToWebelementWrapper(object):
    def __call__(self, f):
        @functools.wraps(f)
        def wrapper(driver_self, *args, **kwds):
            res = f(driver_self, *args, **kwds)
            res = self._convert_result(driver_self._driver, res)
            return res
        return wrapper

    @classmethod
    def _convert_result(cls, driver, res):
        if type(res) is driver._web_element_cls:
            res = cls._convert_into_webelementwrapper(res)
        elif isinstance(res, (list, tuple)):
            for index, item in enumerate(res):
                res[index] = cls._convert_result(driver, item)
        return res

    @classmethod
    def _convert_into_webelementwrapper(cls, webelement):
        try:
            if webelement.tag_name == 'form':
                from webdriverwrapper.forms import Form
                wrapped = Form(webelement)
            elif webelement.tag_name == 'select':
                wrapped = _SelectWrapper(webelement)
            else:
{'fraction_non_alphanumeric': 0.0827262044653349, 'fraction_numerical': 0.0011750881316098707, 'mean_word_length': 3.0188857412653447, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5420983', 'n_tokens_mistral': 1267, 'n_tokens_neox': 1224, 'n_words': 329}