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

Function update_module

scripts/update_cddl.py:335–354  ·  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

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