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

Function flatten_browser_pdl

scripts/update_cdp.py:65–84  ·  view source on GitHub ↗

Preserves the version block and concatenates all included domain .pdl files.

(file_path, chrome_version)

Source from the content-addressed store, hash-verified

63
64
65def flatten_browser_pdl(file_path, chrome_version):
66 """Preserves the version block and concatenates all included domain .pdl files."""
67 with open(file_path) as file:
68 content = file.read()
69 # Extract version block
70 version_match = re.search(r"(version\s+major\s+\d+\s+minor\s+\d+)", content)
71 version_block = version_match.group(1) + "\n\n" if version_match else ""
72 # Find all include lines
73 includes = re.findall(r"include domains/([A-Za-z0-9_]+\.pdl)", content)
74 base_url = f"https://raw.githubusercontent.com/chromium/chromium/{chrome_version}/third_party/blink/public/devtools_protocol/domains/"
75 concatenated = ""
76 for domain_file in includes:
77 url = base_url + domain_file
78 response = http.request("GET", url)
79 if response.status != 200:
80 raise ValueError(f"Fetch failed (HTTP {response.status}): {url}")
81 concatenated += response.data.decode("utf-8") + "\n"
82 # Overwrite the file with version block + concatenated domains
83 with open(file_path, "w") as file:
84 file.write(version_block + concatenated)
85
86
87def add_pdls(chrome_milestone):

Callers 1

add_pdlsFunction · 0.85

Calls 5

readMethod · 0.65
decodeMethod · 0.65
searchMethod · 0.45
requestMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected