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

Function add_pdls

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

Source from the content-addressed store, hash-verified

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