MCPcopy
hub / github.com/psycopg/psycopg / update_file

Function update_file

tools/update_oids.py:230–242  ·  view source on GitHub ↗
(fn: Path, new: list[str])

Source from the content-addressed store, hash-verified

228
229
230def update_file(fn: Path, new: list[str]) -> None:
231 with fn.open("r") as f:
232 lines = f.read().splitlines()
233 istart, iend = (
234 i
235 for i, line in enumerate(lines)
236 if re.match(r"\s*#\s*autogenerated:\s+(start|end)", line)
237 )
238 lines[istart + 1 : iend] = new + [""]
239
240 with fn.open("w") as f:
241 f.write("\n".join(lines))
242 f.write("\n")
243
244
245def parse_cmdline() -> argparse.Namespace:

Callers 4

update_python_typesFunction · 0.70
update_python_oidsFunction · 0.70
update_cython_oidsFunction · 0.70
update_crdb_python_oidsFunction · 0.70

Calls 4

openMethod · 0.45
readMethod · 0.45
writeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected