<commit_before>"""
Use environment variables to configure Selenium remote WebDriver.
For use with SauceLabs (via SauceConnect) or local browsers.
"""

import os
import splinter

import logging
LOGGER = logging.getLogger(__name__)


EXPECTED_ENV_VARS = [
    'SELENIUM_BROWSER',
    'SELENIUM_VERSION',
    'SELENIUM_PLATFORM',
    'SELENIUM_HOST',
    'SELENIUM_PORT',
    'SAUCE_USER_NAME',
    'SAUCE_API_KEY',
]


OPTIONAL_ENV_VARS = [
    'JOB_NAME',
    'BUILD_NUMBER',
]


BROWSERS = ['chrome', 'firefox', 'internet explorer', 'safari']


class BrowserConfigError(Exception):
    """
    Misconfiguration error in the environment variables.
    """
    pass


def browser(tags):
    """
    Interpret environment variables to configure Selenium.
    Performs validation, logging, and sensible defaults.

    `tags` is a list of string tags to apply to the SauceLabs
    job.  If not using SauceLabs, these will be ignored.

    There are two cases:

    1. Local browsers: No environment variables set (default to Firefox locally) or `SELENIUM_BROWSER` set (use that browser locally)

    2. SauceLabs: Set all of the following environment variables:

        * SELENIUM_BROWSER
        * SELENIUM_VERSION
        * SELENIUM_PLATFORM
        * SELENIUM_HOST
        * SELENIUM_PORT
        * SAUCE_USER_NAME
        * SAUCE_API_KEY

    **NOTE:** these are the environment variables set by the SauceLabs
    Jenkins plugin.

    Optionally provide Jenkins info, used to identify jobs to Sauce:

        * JOB_NAME
        * BUILD_NUMBER

    Raises a `BrowserConfigError` if environment variables are missing.
    Returns a `splinter.Browser` object.
    """

    if _use_local_browser():
        browser_name = os.environ.get('SELENIUM_BROWSER', 'firefox')
        LOGGER.info("Using local browser: {0} [Default is firefox]".format(browser_name))
        return splinter.Browser(browser_name)

    else:<commit_msg>Make browser tags optional<commit_after>"""
Use environment variables to configure Selenium remote WebDriver.
For use with SauceLabs (via SauceConnect) or local browsers.
"""

import os
import splinter

import logging
LOGGER = logging.getLogger(__name__)


EXPECTED_ENV_VARS = [
    'SELENIUM_BROWSER',
    'SELENIUM_VERSION',
    'SELENIUM_PLATFORM',
    'SELENIUM_HOST',
    'SELENIUM_PORT',
    'SAUCE_USER_NAME',
    'SAUCE_API_KEY',
]


OPTIONAL_ENV_VARS = [
    'JOB_NAME',
    'BUILD_NUMBER',
]


BROWSERS = ['chrome', 'firefox', 'internet explorer', 'safari']


class BrowserConfigError(Exception):
    """
    Misconfiguration error in the environment variables.
    """
    pass


def browser(tags=None):
    """
    Interpret environment variables to configure Selenium.
    Performs validation, logging, and sensible defaults.

    `tags` is a list of string tags to apply to the SauceLabs
    job.  If not using SauceLabs, these will be ignored.

    There are two cases:

    1. Local browsers: No environment variables set (default to Firefox locally) or `SELENIUM_BROWSER` set (use that browser locally)

    2. SauceLabs: Set all of the following environment variables:

        * SELENIUM_BROWSER
        * SELENIUM_VERSION
        * SELENIUM_PLATFORM
        * SELENIUM_HOST
        * SELENIUM_PORT
        * SAUCE_USER_NAME
        * SAUCE_API_KEY

    **NOTE:** these are the environment variables set by the SauceLabs
    Jenkins plugin.

    Optionally provide Jenkins info, used to identify jobs to Sauce:

        * JOB_NAME
        * BUILD_NUMBER

    Raises a `BrowserConfigError` if environment variables are missing.
    Returns a `splinter.Browser` object.
    """
    if tags is None:
        tags = []

    if _use_local_browser():
        browser_name = os.environ.get('SELENIUM_BROWSER', 'firefox')
        LOGGER.info("Using local browser: {0} [Default is firefox]".format(browser_name))
        return splinter.Browser(browser_name)

    else:
{'fraction_non_alphanumeric': 0.08228659318123559, 'fraction_numerical': 0.0015380671622660857, 'mean_word_length': 3.20021528525296, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7277061', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1207, 'n_words': 359}