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

Function update_module

scripts/update_cddl.py:336–355  ·  view source on GitHub ↗

Rewrite the extension's use_repo block in MODULE.bazel to name every pinned repo. Deliberately not `bazel mod tidy`: that also rewrites every other extension's block and reformats the file, which does not belong in a CDDL repin.

(pinned, vendors)

Source from the content-addressed store, hash-verified

334
335
336def update_module(pinned, vendors):
337 """Rewrite the extension's use_repo block in MODULE.bazel to name every pinned repo.
338
339 Deliberately not `bazel mod tidy`: that also rewrites every other extension's block and
340 reformats the file, which does not belong in a CDDL repin.
341 """
342 names = {BIDI_SPEC_REPO_NAME} | vendor_repo_names(vendors)
343 for shortname, *_ in pinned:
344 names.update(repo_names(shortname))
345 repo_list = "\n".join(f' "{name}",' for name in sorted(names))
346 content = MODULE_FILE.read_text()
347 content, count = re.subn(
348 r"use_repo\(\n webref_cddl_extension,\n.*?\n\)",
349 f"use_repo(\n webref_cddl_extension,\n{repo_list}\n)",
350 content,
351 flags=re.DOTALL,
352 )
353 if count != 1:
354 raise RuntimeError(f"Expected exactly one webref_cddl_extension use_repo block, found {count}")
355 MODULE_FILE.write_text(content)
356
357
358def main():

Callers 1

mainFunction · 0.85

Calls 3

vendor_repo_namesFunction · 0.85
repo_namesFunction · 0.85
updateMethod · 0.80

Tested by

no test coverage detected