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

Function add_pdls

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

Source from the content-addressed store, hash-verified

95
96
97def add_pdls(chrome_milestone):
98 source_dir = root_dir / f"common/devtools/chromium/v{previous_chrome(chrome_milestone)}"
99 target_dir = root_dir / f"common/devtools/chromium/v{new_chrome(chrome_milestone)}"
100 old_dir = root_dir / f"common/devtools/chromium/v{old_chrome(chrome_milestone)}"
101
102 if os.path.isdir(old_dir):
103 shutil.rmtree(old_dir)
104
105 if not target_dir.is_dir() or not any(target_dir.iterdir()):
106 os.makedirs(target_dir, exist_ok=True)
107 if os.path.isdir(source_dir):
108 shutil.copytree(source_dir, target_dir, dirs_exist_ok=True)
109
110 fetch_and_save(
111 f"https://api.github.com/repos/chromium/chromium/contents/third_party/blink/public/devtools_protocol/browser_protocol.pdl?ref={chrome_milestone['version']}",
112 f"{target_dir}/browser_protocol.pdl",
113 )
114
115 flatten_browser_pdl(f"{target_dir}/browser_protocol.pdl", chrome_milestone["version"])
116
117 deps_content = github_get(
118 f"https://api.github.com/repos/chromium/chromium/contents/DEPS?ref={chrome_milestone['version']}"
119 ).data.decode("utf-8")
120 v8_revision_line = next((line for line in deps_content.split("\n") if "v8_revision" in line), None)
121 if v8_revision_line is None:
122 raise ValueError(f"No v8_revision found in DEPS for Chrome {chrome_milestone['version']}")
123 v8_revision = v8_revision_line.split(": ")[1].strip("',")
124 fetch_and_save(
125 f"https://api.github.com/repos/v8/v8/contents/include/js_protocol.pdl?ref={v8_revision}",
126 f"{target_dir}/js_protocol.pdl",
127 )
128
129 # javadocs does not like script tags
130 with open(f"{target_dir}/browser_protocol.pdl", "r+") as file:
131 script_replace = file.read().replace("`<script>`", "`script`")
132 file.seek(0)
133 file.write(script_replace)
134 file.truncate()
135
136
137def 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
github_getFunction · 0.85
splitMethod · 0.80
decodeMethod · 0.65
readMethod · 0.65
writeMethod · 0.45

Tested by

no test coverage detected