MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / add_pdls

Function add_pdls

scripts/update_cdp.py:88–126  ·  view source on GitHub ↗
(chrome_milestone)

Source from the content-addressed store, hash-verified

86
87
88def add_pdls(chrome_milestone):
89 source_dir = root_dir / f"common/devtools/chromium/v{previous_chrome(chrome_milestone)}"
90 target_dir = root_dir / f"common/devtools/chromium/v{new_chrome(chrome_milestone)}"
91 old_dir = root_dir / f"common/devtools/chromium/v{old_chrome(chrome_milestone)}"
92
93 if os.path.isdir(old_dir):
94 shutil.rmtree(old_dir)
95
96 if not target_dir.is_dir() or not any(target_dir.iterdir()):
97 os.makedirs(target_dir, exist_ok=True)
98 if os.path.isdir(source_dir):
99 shutil.copytree(source_dir, target_dir, dirs_exist_ok=True)
100
101 fetch_and_save(
102 f"https://raw.githubusercontent.com/chromium/chromium/{chrome_milestone['version']}/third_party/blink/public/devtools_protocol/browser_protocol.pdl",
103 f"{target_dir}/browser_protocol.pdl",
104 )
105
106 flatten_browser_pdl(f"{target_dir}/browser_protocol.pdl", chrome_milestone["version"])
107
108 deps_content = http.request(
109 "GET",
110 f"https://raw.githubusercontent.com/chromium/chromium/{chrome_milestone['version']}/DEPS",
111 ).data.decode("utf-8")
112 v8_revision_line = next((line for line in deps_content.split("\n") if "v8_revision" in line), None)
113 if v8_revision_line is None:
114 raise ValueError(f"No v8_revision found in DEPS for Chrome {chrome_milestone['version']}")
115 v8_revision = v8_revision_line.split(": ")[1].strip("',")
116 fetch_and_save(
117 f"https://raw.githubusercontent.com/v8/v8/{v8_revision}/include/js_protocol.pdl",
118 f"{target_dir}/js_protocol.pdl",
119 )
120
121 # javadocs does not like script tags
122 with open(f"{target_dir}/browser_protocol.pdl", "r+") as file:
123 script_replace = file.read().replace("`<script>`", "`script`")
124 file.seek(0)
125 file.write(script_replace)
126 file.truncate()
127
128
129def create_new_chrome_files(src_base, chrome_milestone):

Callers 1

update_cdp.pyFile · 0.85

Calls 10

previous_chromeFunction · 0.85
new_chromeFunction · 0.85
old_chromeFunction · 0.85
fetch_and_saveFunction · 0.85
flatten_browser_pdlFunction · 0.85
splitMethod · 0.80
decodeMethod · 0.65
readMethod · 0.65
requestMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected