Skip to content

Commit b49a8eb

Browse files
[py] Use generated Bidi files instead of hand curated ones
1 parent 27e0996 commit b49a8eb

File tree

21 files changed

+16
-5723
lines changed

21 files changed

+16
-5723
lines changed

py/BUILD.bazel

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,11 @@ py_library(
261261
# BiDi protocol support
262262
py_library(
263263
name = "bidi",
264-
srcs = glob(["selenium/webdriver/common/bidi/**/*.py"]),
265-
data = [":mutation-listener"],
264+
srcs = [],
265+
data = [
266+
":create-bidi-src",
267+
":mutation-listener",
268+
],
266269
imports = ["."],
267270
visibility = ["//visibility:public"],
268271
deps = [
@@ -616,12 +619,15 @@ generate_devtools_latest(
616619
browser_versions = BROWSER_VERSIONS,
617620
)
618621

619-
# Pilot BiDi code generation from CDDL specification
622+
# Generate BiDi source files from CDDL specification
620623
generate_bidi(
621624
name = "create-bidi-src",
622625
cddl_file = "//common/bidi/spec:all.cddl",
623626
enhancements_manifest = "//py/private:bidi_enhancements_manifest.py",
624-
extra_srcs = ["//py/private:cdp.py"],
627+
extra_srcs = [
628+
"//py/private:_event_manager.py",
629+
"//py/private:cdp.py",
630+
],
625631
generator = ":generate_bidi",
626632
module_name = "selenium/webdriver/common/bidi",
627633
spec_version = "1.0",

py/private/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
load("@rules_python//python:defs.bzl", "py_binary")
22

33
exports_files([
4+
"_event_manager.py",
45
"bidi_enhancements_manifest.py",
56
"cdp.py",
67
])

py/selenium/webdriver/common/bidi/_event_manager.py renamed to py/private/_event_manager.py

File renamed without changes.

py/private/cdp.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ def import_devtools(ver):
5959
# Attempt to parse and load the 'most recent' devtools module. This is likely
6060
# because cdp has been updated but selenium python has not been released yet.
6161
devtools_path = pathlib.Path(__file__).parents[1].joinpath("devtools")
62-
versions = tuple(f.name for f in devtools_path.iterdir() if f.is_dir())
62+
versions = tuple(
63+
f.name
64+
for f in devtools_path.iterdir()
65+
if f.is_dir() and f.name.startswith("v") and f.name[1:].isdigit()
66+
)
6367
latest = max(int(x[1:]) for x in versions)
6468
selenium_logger = logging.getLogger(__name__)
6569
selenium_logger.debug("Falling back to loading `devtools`: v%s", latest)

py/selenium/webdriver/common/bidi/__init__.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

0 commit comments

Comments
 (0)