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

Function add_pdls

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

Source from the content-addressed store, hash-verified

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