Files
codeql/misc/bazel/3rdparty/patch_defs.py
Paolo Tranquilli 91b3d108bb Python: upgrade cargo dependencies
This required some code changes because of some breaking changes in
`clap` and `tree-sitter`.

Also needed to assign a new bazel repo name to the `crates_vendor` to
avoid name conflicts in `MODULE.bazel`.
2025-02-17 10:56:36 +01:00

17 lines
397 B
Python

import sys
import re
import pathlib
label_re = re.compile(r'"@(vendor.*)//:(.+)-([\d.]+)"')
file = pathlib.Path(sys.argv[1])
temp = file.with_suffix(f'{file.suffix}.tmp')
with open(file) as input, open(temp, "w") as output:
for line in input:
line = label_re.sub(lambda m: f'"@{m[1]}__{m[2]}-{m[3]}//:{m[2].replace("-", "_")}"', line)
output.write(line)
temp.rename(file)