<commit_before>﻿// <copyright file="OperaDriverService.cs" company="WebDriver Committers">
// Copyright 2007-2011 WebDriver committers
// Copyright 2007-2011 Google Inc.
// Portions copyright 2011 Software Freedom Conservancy
//
// 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.
// </copyright>

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using OpenQA.Selenium.Internal;

namespace OpenQA.Selenium.Opera
{
    /// <summary>
    /// Exposes the service provided by the native OperaDriver executable.
    /// </summary>
    public sealed class OperaDriverService : DriverService
    {
        private const string OperaDriverServiceFileName = "operadriver-0.1.0-win32.exe";
        private static readonly Uri OperaDriverDownloadUrl = new Uri("https://github.com/operasoftware/operachromiumdriver/releases");
        private string logPath = string.Empty;
        private string urlPathPrefix = string.Empty;
        private string portServerAddress = string.Empty;
        private int adbPort = -1;
        private bool enableVerboseLogging;

        /// <summary>
        /// Initializes a new instance of the OperaDriverService class.
        /// </summary>
        /// <param name="executablePath">The full path to the OperaDriver executable.</param>
        /// <param name="executableFileName">The file name of the OperaDriver executable.</param>
        /// <param name="port">The port on which the OperaDriver executable should listen.</param>
        private OperaDriverService(string executablePath, string executableFileName, int port)
            : base(executablePath, port, executableFileName, OperaDriverDownloadUrl)
        {
        }

        /// <summary>
        /// Gets or sets the location of the log file written to by the OperaDriver executable.
        /// </summary>
        public string LogPath
        {
            get { return this.logPath; }
            set { this.logPath = value; }
        }

        /// <summary>
        /// Gets or sets the base URL path prefix for commands (e.g., "wd/url").
        /// </summary>
        public string UrlPathPrefix
        {
            get { return this.urlPathPrefix; }
            set { this.urlPathPrefix = value; }
        }

        /// <summary>
        /// Gets or sets the address of a server to contact for reserving a port.
        /// </summary>
        public string PortServerAddress
        {
            get { return this.portServerAddress; }
            set { this.portServerAddress = value; }
        }

        /// <summary>
        /// Gets or sets the port on which the Android Debug Bridge is listening for commands.
        /// </summary>
        public int AndroidDebugBridgePort
        {
            get { return this.adbPort; }
            set { this.adbPort = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether to enable verbose logging for the OperaDriver executable.
        /// Defaults to <see langword="false"/>.
        /// </summary>
        public bool EnableVerboseLogging
        {
            get { return this.enableVerboseLogging; }
            set { this.enableVerboseLogging = value; }
        }

        /// <summary>
        /// Gets the command-line arguments for the driver service.
        /// </summary>
        protected override string CommandLineArguments
        {
            get
            {
                StringBuilder argsBuilder = new StringBuilder(base.CommandLineArguments);
                if (this.adbPort > 0)
                {
                    argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --adb-port={0}", this.adbPort);
                }

                if (this.SuppressInitialDiagnosticInformation)
                {
                    argsBuilder.Append(" --silent");
                }

                if (this.enableVerboseLogging)
                {
                    argsBuilder.Append(" --verbose");
                }

                if (!string.IsNullOrEmpty(this.logPath))
                {
                    argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --log-path={0}", this.logPath);
                }

                if (!string.IsNullOrEmpty(this.urlPathPrefix))
                {
                    argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --url-base={0}", this.urlPathPrefix);
                }

                if (!string.IsNullOrEmpty(this.portServerAddress))
                {
                    argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --port-server={0}", this.portServerAddress);
                }

                return argsBuilder.ToString();
            }
        }

        /// <summary>
        /// Creates a default instance of the OperaDriverService.
        /// </summary>
        /// <returns>A OperaDriverService that implements default settings.</returns>
        public static OperaDriverService CreateDefaultService()
        {
            string serviceDirectory = DriverService.FindDriverServiceExecutable(OperaDriverServiceFileName, OperaDriverDownloadUrl);
            return CreateDefaultService(serviceDirectory);
        }

        /// <summary>
        /// Creates a default instance of the OperaDriverService using a specified path to the OperaDriver executable.
        /// </summary>
        /// <param name="driverPath">The directory containing the OperaDriver executable.</param>
        /// <returns>A OperaDriverService using a random port.</returns>
        public static OperaDriverService CreateDefaultService(string driverPath)
        {
            return CreateDefaultService(driverPath, OperaDriverServiceFileName);
        }

        /// <summary>
        /// Creates a default instance of the OperaDriverService using a specified path to the OperaDriver executable with the given name.
        /// </summary>
        /// <param name="driverPath">The directory containing the OperaDriver executable.</param>
        /// <param name="driverExecutableFileName">The name of the OperaDriver executable file.</param>
        /// <returns>A OperaDriverService using a random port.</returns>
        public static OperaDriverService CreateDefaultService(string driverPath, string driverExecutableFileName)
        {
            return new OperaDriverService(driverPath, driverExecutableFileName, PortUtilities.FindFreePort());
        }
    }
}
<commit_msg>Updating name of operadriver executable for .NET bindings<commit_after>﻿// <copyright file="OperaDriverService.cs" company="WebDriver Committers">
// Copyright 2007-2011 WebDriver committers
// Copyright 2007-2011 Google Inc.
// Portions copyright 2011 Software Freedom Conservancy
//
// 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.
// </copyright>

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using OpenQA.Selenium.Internal;

namespace OpenQA.Selenium.Opera
{
    /// <summary>
    /// Exposes the service provided by the native OperaDriver executable.
    /// </summary>
    public sealed class OperaDriverService : DriverService
    {
        private const string OperaDriverServiceFileName = "operadriver.exe";
        private static readonly Uri OperaDriverDownloadUrl = new Uri("https://github.com/operasoftware/operachromiumdriver/releases");
        private string logPath = string.Empty;
        private string urlPathPrefix = string.Empty;
        private string portServerAddress = string.Empty;
        private int adbPort = -1;
        private bool enableVerboseLogging;

        /// <summary>
        /// Initializes a new instance of the OperaDriverService class.
        /// </summary>
        /// <param name="executablePath">The full path to the OperaDriver executable.</param>
        /// <param name="executableFileName">The file name of the OperaDriver executable.</param>
        /// <param name="port">The port on which the OperaDriver executable should listen.</param>
        private OperaDriverService(string executablePath, string executableFileName, int port)
            : base(executablePath, port, executableFileName, OperaDriverDownloadUrl)
        {
        }

        /// <summary>
        /// Gets or sets the location of the log file written to by the OperaDriver executable.
        /// </summary>
        public string LogPath
        {
            get { return this.logPath; }
            set { this.logPath = value; }
        }

        /// <summary>
        /// Gets or sets the base URL path prefix for commands (e.g., "wd/url").
        /// </summary>
        public string UrlPathPrefix
        {
            get { return this.urlPathPrefix; }
            set { this.urlPathPrefix = value; }
        }

        /// <summary>
        /// Gets or sets the address of a server to contact for reserving a port.
        /// </summary>
        public string PortServerAddress
        {
            get { return this.portServerAddress; }
            set { this.portServerAddress = value; }
        }

        /// <summary>
        /// Gets or sets the port on which the Android Debug Bridge is listening for commands.
        /// </summary>
        public int AndroidDebugBridgePort
        {
            get { return this.adbPort; }
            set { this.adbPort = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether to enable verbose logging for the OperaDriver executable.
        /// Defaults to <see langword="false"/>.
        /// </summary>
        public bool EnableVerboseLogging
        {
            get { return this.enableVerboseLogging; }
            set { this.enableVerboseLogging = value; }
        }

        /// <summary>
        /// Gets the command-line arguments for the driver service.
        /// </summary>
        protected override string CommandLineArguments
        {
            get
            {
                StringBuilder argsBuilder = new StringBuilder(base.CommandLineArguments);
                if (this.adbPort > 0)
                {
                    argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --adb-port={0}", this.adbPort);
                }

                if (this.SuppressInitialDiagnosticInformation)
                {
                    argsBuilder.Append(" --silent");
                }

                if (this.enableVerboseLogging)
                {
                    argsBuilder.Append(" --verbose");
                }

                if (!string.IsNullOrEmpty(this.logPath))
                {
                    argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --log-path={0}", this.logPath);
                }

                if (!string.IsNullOrEmpty(this.urlPathPrefix))
                {
                    argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --url-base={0}", this.urlPathPrefix);
                }

                if (!string.IsNullOrEmpty(this.portServerAddress))
                {
                    argsBuilder.AppendFormat(CultureInfo.InvariantCulture, " --port-server={0}", this.portServerAddress);
                }

                return argsBuilder.ToString();
            }
        }

        /// <summary>
        /// Creates a default instance of the OperaDriverService.
        /// </summary>
        /// <returns>A OperaDriverService that implements default settings.</returns>
        public static OperaDriverService CreateDefaultService()
        {
            string serviceDirectory = DriverService.FindDriverServiceExecutable(OperaDriverServiceFileName, OperaDriverDownloadUrl);
            return CreateDefaultService(serviceDirectory);
        }

        /// <summary>
        /// Creates a default instance of the OperaDriverService using a specified path to the OperaDriver executable.
        /// </summary>
        /// <param name="driverPath">The directory containing the OperaDriver executable.</param>
        /// <returns>A OperaDriverService using a random port.</returns>
        public static OperaDriverService CreateDefaultService(string driverPath)
        {
            return CreateDefaultService(driverPath, OperaDriverServiceFileName);
        }

        /// <summary>
        /// Creates a default instance of the OperaDriverService using a specified path to the OperaDriver executable with the given name.
        /// </summary>
        /// <param name="driverPath">The directory containing the OperaDriver executable.</param>
        /// <param name="driverExecutableFileName">The name of the OperaDriver executable file.</param>
        /// <returns>A OperaDriverService using a random port.</returns>
        public static OperaDriverService CreateDefaultService(string driverPath, string driverExecutableFileName)
        {
            return new OperaDriverService(driverPath, driverExecutableFileName, PortUtilities.FindFreePort());
        }
    }
}

{'fraction_non_alphanumeric': 0.09358365702776579, 'fraction_numerical': 0.004675586246583226, 'mean_word_length': 2.071128782858405, 'pattern_counts': {'":': 0, '<': 89, '<?xml version=': 0, '>': 91, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, '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': '3826160', 'n_tokens_mistral': 3378, 'n_tokens_neox': 3216, 'n_words': 1013}