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

Function flatten_browser_pdl

scripts/update_cdp.py:78–95  ·  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

76
77
78def flatten_browser_pdl(file_path, chrome_version):
79 """Preserves the version block and concatenates all included domain .pdl files."""
80 with open(file_path) as file:
81 content = file.read()
82 # Extract version block
83 version_match = re.search(r"(version\s+major\s+\d+\s+minor\s+\d+)", content)
84 version_block = version_match.group(1) + "\n\n" if version_match else ""
85 # Find all include lines
86 includes = re.findall(r"include domains/([A-Za-z0-9_]+\.pdl)", content)
87 base_url = (
88 "https://api.github.com/repos/chromium/chromium/contents/third_party/blink/public/devtools_protocol/domains/"
89 )
90 concatenated = ""
91 for domain_file in includes:
92 concatenated += github_fetch(f"{base_url}{domain_file}?ref={chrome_version}").decode("utf-8") + "\n"
93 # Overwrite the file with version block + concatenated domains
94 with open(file_path, "w") as file:
95 file.write(version_block + concatenated)
96
97
98def add_pdls(chrome_milestone):

Callers 1

add_pdlsFunction · 0.85

Calls 5

github_fetchFunction · 0.85
readMethod · 0.65
decodeMethod · 0.65
searchMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected