Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/devtools/convert_protocol_to_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def main(argv):
parser.add_argument("json_file", help="The .json output file write.")
args = parser.parse_args(argv)
file_name = os.path.normpath(args.pdl_file)
input_file = open(file_name, "r")
input_file = open(file_name)
pdl_string = input_file.read()
protocol = pdl.loads(pdl_string, file_name, args.map_binary_to_string)
input_file.close()
Expand Down
3 changes: 1 addition & 2 deletions common/devtools/pdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

from __future__ import print_function
import collections
import json
import re
Expand Down Expand Up @@ -166,7 +165,7 @@ def parse(data, file_name, map_binary_to_string=False):
enumliterals.append(trimLine)
continue

print('Error in %s:%s, illegal token: \t%s' % (file_name, i, line))
print(f'Error in {file_name}:{i}, illegal token: \t{line}')
sys.exit(1)
return protocol

Expand Down
44 changes: 22 additions & 22 deletions javascript/private/gen_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def write_atom_literal(out, name, contents, lang, utf8):
else:
line_format = " L\"{}\",\n"
elif "java" == lang:
line_format = " .append\(\"{}\")\n"
line_format = " .append\\(\"{}\")\n"
else:
raise RuntimeError("Unknown language: %s " % lang)

Expand All @@ -47,7 +47,7 @@ def write_atom_literal(out, name, contents, lang, utf8):
if "cc" == lang or "hh" == lang:
string_type = "std::string" if utf8 else "std::wstring"
char_type = "char" if utf8 else "wchar_t"
out.write("const %s* const %s[] = {\n" % (char_type, name))
out.write(f"const {char_type}* const {name}[] = {{\n")
elif "java" == lang:
out.write(" %s(new StringBuilder()\n" % name)
else:
Expand Down Expand Up @@ -75,43 +75,43 @@ def write_atom_literal(out, name, contents, lang, utf8):
def generate_header(file_name, out, js_map, just_declare, utf8):
define_guard = "WEBDRIVER_%s" % os.path.basename(file_name.upper()).replace(".", "_")
include_stddef = "" if utf8 else "\n#include <stddef.h> // For wchar_t."
out.write("""%s
out.write("""{}

/* AUTO GENERATED - DO NOT EDIT BY HAND */
#ifndef %s
#define %s
%s
#ifndef {}
#define {}
{}
#include <string> // For std::(w)string.

namespace webdriver {
namespace atoms {
namespace webdriver {{
namespace atoms {{

""" % (_copyright, define_guard, define_guard, include_stddef))
""".format(_copyright, define_guard, define_guard, include_stddef))

string_type = "std::string" if utf8 else "std::wstring"
char_type = "char" if utf8 else "wchar_t"

for (name, file) in js_map.items():
if just_declare:
out.write("extern const %s* const %s[];\n" % (char_type, name.upper()))
out.write(f"extern const {char_type}* const {name.upper()}[];\n")
else:
contents = open(file, "r").read()
contents = open(file).read()
write_atom_literal(out, name, contents, "hh", utf8)

out.write("""
static inline %s asString(const %s* const atom[]) {
%s source;
for (int i = 0; atom[i] != NULL; i++) {
static inline {} asString(const {}* const atom[]) {{
{} source;
for (int i = 0; atom[i] != NULL; i++) {{
source += atom[i];
}
}}
return source;
}
}}

} // namespace atoms
} // namespace webdriver
}} // namespace atoms
}} // namespace webdriver

#endif // %s
""" % (string_type, char_type, string_type, define_guard))
#endif // {}
""".format(string_type, char_type, string_type, define_guard))

def generate_cc_source(out, js_map, utf8):
out.write("""%s
Expand All @@ -127,7 +127,7 @@ def generate_cc_source(out, js_map, utf8):
""" % _copyright)

for (name, file) in js_map.items():
contents = open(file, "r").read()
contents = open(file).read()
write_atom_literal(out, name, contents, "cc", utf8)

out.write("""
Expand All @@ -152,7 +152,7 @@ def generate_java_source(file_name, out, preamble, js_map):
""" % class_name)

for (name, file) in js_map.items():
contents = open(file, "r").read()
contents = open(file).read()
write_atom_literal(out, name, contents, "java", True)

out.write("""
Expand Down
3 changes: 1 addition & 2 deletions py/selenium/webdriver/remote/webelement.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
from base64 import encodebytes
from hashlib import md5 as md5_hash
from io import BytesIO
from typing import List

from selenium.common.exceptions import JavascriptException
from selenium.common.exceptions import WebDriverException
Expand Down Expand Up @@ -414,7 +413,7 @@ def find_element(self, by=By.ID, value=None) -> WebElement:
by, value = self._parent.locator_converter.convert(by, value)
return self._execute(Command.FIND_CHILD_ELEMENT, {"using": by, "value": value})["value"]

def find_elements(self, by=By.ID, value=None) -> List[WebElement]:
def find_elements(self, by=By.ID, value=None) -> list[WebElement]:
"""Find elements given a By strategy and locator.

:Usage:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_download_file(driver, pages):
driver.download_file(file_name, target_directory)

target_file = os.path.join(target_directory, file_name)
with open(target_file, "r") as file:
with open(target_file) as file:
assert "Hello, World!" in file.read()


Expand Down
34 changes: 17 additions & 17 deletions scripts/pinned_browsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def chrome(selected_version):
content = """
http_archive(
name = "linux_chrome",
url = "%s",
sha256 = "%s",
url = "{}",
sha256 = "{}",
build_file_content = \"\"\"
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -137,7 +137,7 @@ def chrome(selected_version):
\"\"\",
)

""" % (
""".format(
linux,
sha,
)
Expand All @@ -147,8 +147,8 @@ def chrome(selected_version):

content += """ http_archive(
name = "mac_chrome",
url = "%s",
sha256 = "%s",
url = "{}",
sha256 = "{}",
strip_prefix = "chrome-mac-x64",
patch_cmds = [
"mv 'Google Chrome for Testing.app' Chrome.app",
Expand All @@ -167,7 +167,7 @@ def chrome(selected_version):
\"\"\",
)

""" % (
""".format(
mac,
sha,
)
Expand Down Expand Up @@ -206,11 +206,11 @@ def edge():
content += """
pkg_archive(
name = "mac_edge",
url = "%s",
sha256 = "%s",
move = {
"MicrosoftEdge-%s.pkg/Payload/Microsoft Edge.app": "Edge.app",
},
url = "{}",
sha256 = "{}",
move = {{
"MicrosoftEdge-{}.pkg/Payload/Microsoft Edge.app": "Edge.app",
}},
build_file_content = \"\"\"
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -223,7 +223,7 @@ def edge():
)
\"\"\",
)
""" % (
""".format(
mac,
mac_hash.lower(),
mac_version,
Expand All @@ -233,8 +233,8 @@ def edge():
content += """
deb_archive(
name = "linux_edge",
url = "%s",
sha256 = "%s",
url = "{}",
sha256 = "{}",
build_file_content = \"\"\"
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
Expand All @@ -252,7 +252,7 @@ def edge():
)
\"\"\",
)
""" % (
""".format(
linux,
linux_hash.lower()
)
Expand Down Expand Up @@ -402,11 +402,11 @@ def firefox_version_data():


def firefox_linux(version):
return "https://ftp.mozilla.org/pub/firefox/releases/%s/linux-x86_64/en-US/firefox-%s.tar.bz2" % (version, version)
return f"https://ftp.mozilla.org/pub/firefox/releases/{version}/linux-x86_64/en-US/firefox-{version}.tar.bz2"


def firefox_mac(version):
return "https://ftp.mozilla.org/pub/firefox/releases/%s/mac/en-US/Firefox%%20%s.dmg" % (version, version)
return f"https://ftp.mozilla.org/pub/firefox/releases/{version}/mac/en-US/Firefox%20{version}.dmg"


def print_firefox(version, workspace_name, sha_linux, sha_mac):
Expand Down
2 changes: 1 addition & 1 deletion scripts/update_copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, comment_characters='//', prefix=None):

def update(self, files):
for file in files:
with open(file, 'r', encoding='utf-8-sig') as f:
with open(file, encoding='utf-8-sig') as f:
lines = f.readlines()

index = -1
Expand Down
Loading